Skip to content

Commit 3f0a9e3

Browse files
chore(husky): update branch naming guide and validation script
Expanded the branch naming convention to allow both two-level and three-level formats (e.g., <type>/<description> and <type>/<domain>/<description>), clarified allowed and forbidden characters, and updated examples in the documentation. Adjusted the validation script to enforce the new rules, including stricter character checks and support for the new format.
1 parent d9a76e7 commit 3f0a9e3

File tree

2 files changed

+57
-34
lines changed

2 files changed

+57
-34
lines changed

.husky/husky-guide.md

Lines changed: 53 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88

99
### 허용 타입
1010

11-
| 타입 | 설명 | 예시 |
12-
|------|------|------|
13-
| `feat` | 새로운 기능 추가 | `feat: 사용자 인증 추가` |
14-
| `fix` | 버그 수정 | `fix(api): null 응답 처리` |
15-
| `docs` | 문서 수정 | `docs: 설치 가이드 업데이트` |
16-
| `style` | 코드 스타일 변경 | `style: 코드 포맷팅` |
17-
| `refactor` | 코드 리팩토링 | `refactor(auth): 로직 개선` |
18-
| `test` | 테스트 추가/수정 | `test: 유닛 테스트 추가` |
19-
| `chore` | 빌드/설정 변경 | `chore: 의존성 업데이트` |
20-
| `build` | 빌드 시스템/외부 의존성 변경 | `build: webpack 설정 업데이트` |
21-
| `ci` | CI 설정 파일/스크립트 변경 | `ci: GitHub Actions 워크플로우 추가` |
22-
| `revert` | 이전 커밋 되돌리기 | `revert: feat(auth) 커밋 되돌림` |
11+
| 타입 | 설명 | 예시 |
12+
|------------|------------------|-------------------------------|
13+
| `feat` | 새로운 기능 추가 | `feat: 사용자 인증 추가` |
14+
| `fix` | 버그 수정 | `fix(api): null 응답 처리` |
15+
| `docs` | 문서 수정 | `docs: 설치 가이드 업데이트` |
16+
| `style` | 코드 스타일 변경 | `style: 코드 포맷팅` |
17+
| `refactor` | 코드 리팩토링 | `refactor(auth): 로직 개선` |
18+
| `test` | 테스트 추가/수정 | `test: 유닛 테스트 추가` |
19+
| `chore` | 빌드/설정 변경 | `chore: 의존성 업데이트` |
20+
| `build` | 빌드 시스템/외부 의존성 변경 | `build: webpack 설정 업데이트` |
21+
| `ci` | CI 설정 파일/스크립트 변경 | `ci: GitHub Actions 워크플로우 추가` |
22+
| `revert` | 이전 커밋 되돌리기 | `revert: feat(auth) 커밋 되돌림` |
2323

2424
### 예시
2525

@@ -38,38 +38,60 @@
3838

3939
**실행 시점**: `git push` 시 (푸시 전)
4040
**스크립트**: `validate-branch.cjs`
41-
**형식**: `<type>/<description>`
41+
**형식**: `<type>/<description>` 또는 `<type>/<domain>/<description>`
42+
**허용 문자**: 소문자, 숫자, 특수문자
43+
**금지 문자**: 대문자, 언더스코어(_), 공백, 슬래시(/)
4244

4345
### 허용 타입
4446

45-
| 타입 | 설명 | 예시 |
46-
|------|------|------|
47-
| `feature` | 새로운 기능 개발 | `feature/user-authentication` |
48-
| `fix` | 버그 수정 | `fix/login-bug` |
49-
| `hotfix` | 긴급 버그 수정 | `hotfix/critical-security-issue` |
50-
| `release` | 릴리스 준비 | `release/v1.0.0` |
51-
| `refactor` | 코드 리팩토링 | `refactor/auth-logic` |
52-
| `docs` | 문서 업데이트 | `docs/installation-guide` |
53-
| `test` | 테스트 추가 | `test/unit-tests` |
54-
| `chore` | 유지보수 작업 | `chore/update-deps` |
55-
| `style` | 스타일 개선 | `style/format-code` |
56-
| `copilot` | GitHub Copilot 지원 개발 | `copilot/add-validation` |
57-
| `claude` | Claude AI 지원 개발 | `claude/refactor-api` |
47+
| 타입 | 설명 | 예시 |
48+
|------------|----------------------|----------------------------------|
49+
| `feature` | 새로운 기능 개발 | `feature/user-authentication` |
50+
| `fix` | 버그 수정 | `fix/login-bug` |
51+
| `hotfix` | 긴급 버그 수정 | `hotfix/critical-security-issue` |
52+
| `release` | 릴리스 준비 | `release/v1.0.0` |
53+
| `refactor` | 코드 리팩토링 | `refactor/auth-logic` |
54+
| `docs` | 문서 업데이트 | `docs/installation-guide` |
55+
| `test` | 테스트 추가 | `test/unit-tests` |
56+
| `chore` | 유지보수 작업 | `chore/update-deps` |
57+
| `style` | 스타일 개선 | `style/format-code` |
58+
| `copilot` | GitHub Copilot 지원 개발 | `copilot/add-validation` |
59+
| `claude` | Claude AI 지원 개발 | `claude/refactor-api` |
5860

5961
### 보호 브랜치 (직접 푸시 허용)
6062

6163
`main`, `master`, `develop`, `staging`
6264

6365
### 예시
6466

67+
#### 2단계 형식 (기본)
68+
6569
```bash
6670
✅ feature/user-authentication
67-
✅ fix/login-bug
71+
✅ fix/404-error
6872
✅ copilot/add-validation
6973
✅ claude/refactor-api
74+
✅ hotfix/security-patch-2024
75+
✅ release/1.0.0
76+
```
77+
78+
#### 3단계 형식 (도메인 포함)
79+
80+
```bash
81+
✅ feature/frontend/user-authentication
82+
✅ fix/api/null-response
83+
✅ refactor/backend/auth-logic
84+
✅ docs/api/endpoint-guide
85+
✅ test/integration/payment-flow
86+
✅ fix/api/404-error
87+
```
7088

71-
❌ feature_user_auth # 구분자 오류 (/ 사용)
72-
❌ Feature/user-auth # 대문자 사용 금지
73-
❌ feature/User-Auth # 설명에 대문자 사용 금지
74-
❌ my-feature # 타입 누락
89+
#### 잘못된 형식
90+
91+
```bash
92+
❌ Feature/Frontend/User-auth # 타입, 도메인, 설명에 대문자 사용 금지
93+
❌ my-feature # 타입 누락
94+
❌ feature/add_function # 언더스코어 사용 금지
95+
❌ feature/a/b/c # 4단계 이상 금지
96+
❌ feature/ # 설명 누락
7597
```

.husky/validate-branch.cjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const {execSync} = require('child_process');
44

55
// 허용 규칙
66
const validTypes = ['feature', 'fix', 'hotfix', 'release', 'refactor', 'docs', 'test', 'chore', 'style', 'copilot', 'claude'];
7-
const validPattern = '<type>/<description>';
7+
const validPattern = '<type>/<description> 또는 <type>/<domain>/<description>';
88

99
// 현재 브랜치명 확인
1010
let currentBranch;
@@ -21,8 +21,9 @@ if (protectedBranches.includes(currentBranch)) {
2121
process.exit(0);
2222
}
2323

24-
// 패턴: `type/description`
25-
const branchPattern = new RegExp(`^(${validTypes.join('|')})\\/[a-z][a-z0-9-]*$`);
24+
// 패턴: `type/description` 또는 `type/domain/description`
25+
// 허용: 소문자, 숫자, 특수문자 (단, 대문자/언더스코어/공백/슬래시 제외)
26+
const branchPattern = new RegExp(`^(${validTypes.join('|')})\\/[a-z0-9][^A-Z_\\s\\/]*(\\/[a-z0-9][^A-Z_\\s\\/]*)?$`);
2627
if (!branchPattern.test(currentBranch)) {
2728
console.error(`* 잘못된 형식 : ${currentBranch}`);
2829
console.error(`* 올바른 형식 : ${validPattern}`);

0 commit comments

Comments
 (0)