|
| 1 | +# @naverpay/commit-helper |
| 2 | + |
| 3 | +> ๋ธ๋์น ์ด๋ฆ์ ๊ธฐ๋ฐ์ผ๋ก ์ปค๋ฐ ๋ฉ์์ง์ ์ด์ ๋ฒํธ๋ฅผ ์๋์ผ๋ก ์ถ๊ฐํ๊ณ ์ค์ ๋ธ๋์น๋ฅผ ๋ณดํธํ๋ ๋๊ตฌ |
| 4 | +
|
| 5 | +## ์ค์น |
| 6 | + |
| 7 | +```bash |
| 8 | +npm install --save-dev @naverpay/commit-helper |
| 9 | +# or |
| 10 | +yarn add -D @naverpay/commit-helper |
| 11 | +# or |
| 12 | +pnpm add -D @naverpay/commit-helper |
| 13 | +``` |
| 14 | + |
| 15 | +## ๋น ๋ฅธ ์์ |
| 16 | + |
| 17 | +### 1. Husky ์ค์น (์์ง ์ค์นํ์ง ์์ ๊ฒฝ์ฐ) |
| 18 | + |
| 19 | +```bash |
| 20 | +npm install --save-dev husky |
| 21 | +npx husky init |
| 22 | +``` |
| 23 | + |
| 24 | +### 2. commit-msg ํ
์ถ๊ฐ |
| 25 | + |
| 26 | +```bash |
| 27 | +echo 'npx --yes @naverpay/commit-helper@latest $1' > .husky/commit-msg |
| 28 | +chmod +x .husky/commit-msg |
| 29 | +``` |
| 30 | + |
| 31 | +### 3. ์ปค๋ฐ ์์ฑ |
| 32 | + |
| 33 | +```bash |
| 34 | +git checkout -b feature/123-new-feature |
| 35 | +git add . |
| 36 | +git commit -m "์๋ก์ด ๊ธฐ๋ฅ ์ถ๊ฐ" |
| 37 | +# ๊ฒฐ๊ณผ: [#123] ์๋ก์ด ๊ธฐ๋ฅ ์ถ๊ฐ |
| 38 | +``` |
| 39 | + |
| 40 | +## ์ฃผ์ ๊ธฐ๋ฅ |
| 41 | + |
| 42 | +### ๐ท๏ธ ์๋ ์ด์ ํ๊น
|
| 43 | + |
| 44 | +๋ธ๋์น ์ด๋ฆ์์ ์ด์ ๋ฒํธ๋ฅผ ์ถ์ถํ์ฌ ์ปค๋ฐ ๋ฉ์์ง์ ์ถ๊ฐ: |
| 45 | + |
| 46 | +- `feature/123` โ `[#123] ๋ฉ์์ง` |
| 47 | +- `qa/456` โ `[your-org/your-repo#456] ๋ฉ์์ง` |
| 48 | +- `hotfix/789-urgent` โ `[#789] ๋ฉ์์ง` |
| 49 | + |
| 50 | +### ๐ก๏ธ ๋ธ๋์น ๋ณดํธ |
| 51 | + |
| 52 | +๋ณดํธ๋ ๋ธ๋์น์ ์ง์ ์ปค๋ฐ ๋ฐฉ์ง: |
| 53 | + |
| 54 | +- ๊ธฐ๋ณธ๊ฐ: `main`, `master`, `develop` |
| 55 | +- ์ค์ ์ผ๋ก ์ปค์คํฐ๋ง์ด์ง ๊ฐ๋ฅ |
| 56 | + |
| 57 | +### โ๏ธ ์ ์ฐํ ์ค์ |
| 58 | + |
| 59 | +์ปค์คํ
๊ท์น๊ณผ ์๊ฒฉ ์ค์ ์์์ ์ง์ํฉ๋๋ค. |
| 60 | + |
| 61 | +## ์ค์ |
| 62 | + |
| 63 | +ํ๋ก์ ํธ ๋ฃจํธ์ `.commithelperrc.json` ํ์ผ ์์ฑ: |
| 64 | + |
| 65 | +```json |
| 66 | +{ |
| 67 | + "protect": ["main", "master", "develop", "staging"], |
| 68 | + "rules": { |
| 69 | + "feature": null, |
| 70 | + "bugfix": null, |
| 71 | + "hotfix": null, |
| 72 | + "qa": "naverpay/qa-issues", |
| 73 | + "docs": "naverpay/documentation" |
| 74 | + } |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +### ์ค์ ์ต์
|
| 79 | + |
| 80 | +#### `protect` (๋ฐฐ์ด) |
| 81 | + |
| 82 | +์ง์ ์ปค๋ฐ์ ์ฐจ๋จํ ๋ธ๋์น ์ด๋ฆ ๋ชฉ๋ก |
| 83 | + |
| 84 | +- ๊ธฐ๋ณธ๊ฐ: `["main", "master", "develop"]` |
| 85 | + |
| 86 | +#### `rules` (๊ฐ์ฒด) |
| 87 | + |
| 88 | +๋ธ๋์น ์ ๋์ฌ์ ์ ์ฅ์ ์ด๋ฆ์ ๋งคํ |
| 89 | + |
| 90 | +- ํค: ๋ธ๋์น ์ ๋์ฌ (์: `"feature"`) |
| 91 | +- ๊ฐ: ์ ์ฅ์ ์ด๋ฆ ๋๋ ํ์ฌ ์ ์ฅ์์ธ ๊ฒฝ์ฐ `null` |
| 92 | + |
| 93 | +#### `extends` (๋ฌธ์์ด) |
| 94 | + |
| 95 | +์ค์ ์ ์์๋ฐ์ URL: |
| 96 | + |
| 97 | +```json |
| 98 | +{ |
| 99 | + "extends": "https://raw.githubusercontent.com/naverpay/standards/main/.commithelperrc.json" |
| 100 | +} |
| 101 | +``` |
| 102 | + |
| 103 | +## ์์ |
| 104 | + |
| 105 | +### ๊ธฐ๋ณธ ๊ธฐ๋ฅ ๋ธ๋์น |
| 106 | + |
| 107 | +```bash |
| 108 | +git checkout -b feature/NP-1234-๊ฒฐ์ -ํตํฉ |
| 109 | +git commit -m "๊ฒฐ์ ๊ฒ์ดํธ์จ์ด ๊ตฌํ" |
| 110 | +# ๊ฒฐ๊ณผ: [#1234] ๊ฒฐ์ ๊ฒ์ดํธ์จ์ด ๊ตฌํ |
| 111 | +``` |
| 112 | + |
| 113 | +### ์ธ๋ถ ์ ์ฅ์ ์ฐธ์กฐ |
| 114 | + |
| 115 | +์ค์ ํ์ผ: |
| 116 | + |
| 117 | +```json |
| 118 | +{ |
| 119 | + "rules": { |
| 120 | + "qa": "naverpay/qa-tracker" |
| 121 | + } |
| 122 | +} |
| 123 | +``` |
| 124 | + |
| 125 | +```bash |
| 126 | +git checkout -b qa/789-๊ฒฐ์ -ํ๋ก์ฐ-ํ
์คํธ |
| 127 | +git commit -m "๊ฒฐ์ E2E ํ
์คํธ ์ถ๊ฐ" |
| 128 | +# ๊ฒฐ๊ณผ: [naverpay/qa-tracker#789] ๊ฒฐ์ E2E ํ
์คํธ ์ถ๊ฐ |
| 129 | +``` |
| 130 | + |
| 131 | +### ๋ณดํธ๋ ๋ธ๋์น |
| 132 | + |
| 133 | +```bash |
| 134 | +git checkout main |
| 135 | +git commit -m "์ง์ ์ปค๋ฐ" |
| 136 | +# ์ค๋ฅ: โ ๋ณดํธ๋ ๋ธ๋์น 'main'์ ์ง์ ์ปค๋ฐํ ์ ์์ต๋๋ค! |
| 137 | +# ๊ธฐ๋ฅ ๋ธ๋์น๋ฅผ ์์ฑํ๊ณ ํ ๋ฆฌํ์คํธ๋ฅผ ์ฌ์ฉํ์ธ์. |
| 138 | +``` |
| 139 | + |
| 140 | +## ๊ณ ๊ธ ์ฌ์ฉ๋ฒ |
| 141 | + |
| 142 | +### Lefthook ์ฐ๋ |
| 143 | + |
| 144 | +Husky ๋์ Lefthook์ ์ ํธํ๋ ๊ฒฝ์ฐ: |
| 145 | + |
| 146 | +```yaml |
| 147 | +# lefthook.yml |
| 148 | +commit-msg: |
| 149 | + scripts: |
| 150 | + 'commit-helper': |
| 151 | + runner: npx --yes @naverpay/commit-helper@latest {1} |
| 152 | +``` |
| 153 | +
|
| 154 | +### CI/CD ์ฐ๋ |
| 155 | +
|
| 156 | +CI์์ ์ปค๋ฐ ๋ฉ์์ง ๊ฒ์ฆ: |
| 157 | +
|
| 158 | +```yaml |
| 159 | +# .github/workflows/pr.yml |
| 160 | +- name: ์ปค๋ฐ ๋ฉ์์ง ๊ฒ์ฆ |
| 161 | + run: | |
| 162 | + git log --format=%s origin/main..HEAD | while read msg; do |
| 163 | + if ! echo "$msg" | grep -qE '^\[[#A-Za-z0-9-/]+\]'; then |
| 164 | + echo "์๋ชป๋ ์ปค๋ฐ ๋ฉ์์ง: $msg" |
| 165 | + exit 1 |
| 166 | + fi |
| 167 | + done |
| 168 | +``` |
| 169 | +
|
| 170 | +## API |
| 171 | +
|
| 172 | +### CLI ์ฌ์ฉ๋ฒ |
| 173 | +
|
| 174 | +```bash |
| 175 | +npx @naverpay/commit-helper <commit-msg-file> |
| 176 | +``` |
| 177 | + |
| 178 | +- **๋งค๊ฐ๋ณ์**: |
| 179 | + - `commit-msg-file` (๋ฌธ์์ด): ์ปค๋ฐ ๋ฉ์์ง ํ์ผ ๊ฒฝ๋ก (git hook์ด ์ ๊ณต) |
| 180 | +- **๋ฐํ๊ฐ**: ์ฑ๊ณต ์ ์ข
๋ฃ ์ฝ๋ 0, ์คํจ ์ 1 |
| 181 | +- **์๋ฌ**: ์๋ชป๋ ์ค์ ์ด๋ ๋ณดํธ๋ ๋ธ๋์น์ธ ๊ฒฝ์ฐ stderr๋ก ์๋ฌ ๋ฉ์์ง ์ถ๋ ฅ |
| 182 | + |
| 183 | +## ์์ฃผ ๋ฌป๋ ์ง๋ฌธ |
| 184 | + |
| 185 | +**Q: ์ด๋ฏธ ์ด์ ํ๊ทธ๊ฐ ์๋ ๊ฒฝ์ฐ์๋ ์๋ํ๋์?** |
| 186 | +A: ๋ค, ์ปค๋ฐ ๋ฉ์์ง์ ์ด๋ฏธ `[#123]` ๊ฐ์ ํ๊ทธ๊ฐ ์์ผ๋ฉด commit-helper๋ ๊ฑด๋๋๋๋ค. |
| 187 | + |
| 188 | +**Q: ์ฌ๋ฌ ์ด์ ๋ฒํธ๋ฅผ ์ฌ์ฉํ ์ ์๋์?** |
| 189 | +A: ๋ธ๋์น ์ด๋ฆ์์๋ ํ๋์ ์ด์ ๋ฒํธ๋ง ์ง์ํ์ง๋ง, ์ปค๋ฐ ๋ฉ์์ง์ ์๋์ผ๋ก ์ถ๊ฐํ ์ ์์ต๋๋ค. |
| 190 | + |
| 191 | +**Q: ์ด๋ค ๋ธ๋์น ์ด๋ฆ ํ์์ ์ง์ํ๋์?** |
| 192 | +A: ์ฌ๋์ ๋ค์ ์ซ์๊ฐ ์๋ ๋ชจ๋ ํ์: `feature/123`, `feature/123-์ค๋ช
`, `feature/123_์ค๋ช
` |
| 193 | + |
| 194 | +**Q: ์ผ์์ ์ผ๋ก ๋ณดํธ๋ฅผ ์ฐํํ๋ ค๋ฉด?** |
| 195 | +A: `--no-verify` ํ๋๊ทธ ์ฌ์ฉ: `git commit --no-verify -m "๊ธด๊ธ ์์ "` |
| 196 | + |
| 197 | +## ๋ฌธ์ ํด๊ฒฐ |
| 198 | + |
| 199 | +### ํ
์ด ์คํ๋์ง ์์ |
| 200 | + |
| 201 | +1. ํ์ผ ๊ถํ ํ์ธ: `ls -la .husky/commit-msg` |
| 202 | +2. Husky ์ค์น ํ์ธ: `npx husky install` |
| 203 | + |
| 204 | +### ์ค์ ์ด ๋ก๋๋์ง ์์ |
| 205 | + |
| 206 | +1. ํ์ผ ์ด๋ฆ ํ์ธ: `.commithelperrc.json` (์ ์ผ๋ก ์์) |
| 207 | +2. JSON ๋ฌธ๋ฒ ๊ฒ์ฆ |
| 208 | + |
| 209 | +## ๋ผ์ด์ ์ค |
| 210 | + |
| 211 | +MIT |
0 commit comments