@k2works/claude-code-booster 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/assets/.claude/README.md +54 -136
- package/lib/assets/.claude/assets/.gitkeep +0 -0
- package/lib/assets/.claude/commands/git-commit.md +47 -0
- package/lib/assets/.claude/commands/ops.md +16 -16
- package/lib/assets/.claude/scripts/.gitkeep +0 -0
- package/lib/assets/README.md +77 -3
- package/lib/assets/apps/.gitkeep +0 -0
- package/package.json +1 -1
- package/lib/assets/.claude/agents/roles/analyzer.md +0 -267
- package/lib/assets/.claude/agents/roles/architect.md +0 -233
- package/lib/assets/.claude/agents/roles/backend.md +0 -303
- package/lib/assets/.claude/agents/roles/frontend.md +0 -294
- package/lib/assets/.claude/agents/roles/mobile.md +0 -309
- package/lib/assets/.claude/agents/roles/performance.md +0 -254
- package/lib/assets/.claude/agents/roles/qa.md +0 -266
- package/lib/assets/.claude/agents/roles/reviewer.md +0 -252
- package/lib/assets/.claude/agents/roles/security.md +0 -392
- package/lib/assets/.claude/assets/confirm.mp3 +0 -0
- package/lib/assets/.claude/assets/perfect.mp3 +0 -0
- package/lib/assets/.claude/assets/silent.wav +0 -0
- package/lib/assets/.claude/commands/analyze-dependencies.md +0 -158
- package/lib/assets/.claude/commands/analyze-performance.md +0 -116
- package/lib/assets/.claude/commands/check-fact.md +0 -104
- package/lib/assets/.claude/commands/check-github-ci.md +0 -53
- package/lib/assets/.claude/commands/check-prompt.md +0 -461
- package/lib/assets/.claude/commands/commit-message.md +0 -348
- package/lib/assets/.claude/commands/context7.md +0 -50
- package/lib/assets/.claude/commands/design-patterns.md +0 -186
- package/lib/assets/.claude/commands/explain-code.md +0 -75
- package/lib/assets/.claude/commands/fix-error.md +0 -258
- package/lib/assets/.claude/commands/multi-role.md +0 -291
- package/lib/assets/.claude/commands/next.md +0 -136
- package/lib/assets/.claude/commands/pr-auto-update.md +0 -460
- package/lib/assets/.claude/commands/pr-create.md +0 -249
- package/lib/assets/.claude/commands/pr-feedback.md +0 -143
- package/lib/assets/.claude/commands/pr-issue.md +0 -78
- package/lib/assets/.claude/commands/pr-list.md +0 -66
- package/lib/assets/.claude/commands/pr-review.md +0 -142
- package/lib/assets/.claude/commands/refactor.md +0 -147
- package/lib/assets/.claude/commands/role-debate.md +0 -571
- package/lib/assets/.claude/commands/role-help.md +0 -276
- package/lib/assets/.claude/commands/role.md +0 -360
- package/lib/assets/.claude/commands/screenshot.md +0 -103
- package/lib/assets/.claude/commands/search-gemini.md +0 -66
- package/lib/assets/.claude/commands/semantic-commit.md +0 -1129
- package/lib/assets/.claude/commands/sequential-thinking.md +0 -90
- package/lib/assets/.claude/commands/show-plan.md +0 -59
- package/lib/assets/.claude/commands/smart-review.md +0 -174
- package/lib/assets/.claude/commands/spec.md +0 -559
- package/lib/assets/.claude/commands/style-ai-writing.md +0 -186
- package/lib/assets/.claude/commands/task.md +0 -223
- package/lib/assets/.claude/commands/tech-debt.md +0 -87
- package/lib/assets/.claude/commands/ultrathink.md +0 -65
- package/lib/assets/.claude/commands/update-dart-doc.md +0 -202
- package/lib/assets/.claude/commands/update-doc-string.md +0 -306
- package/lib/assets/.claude/commands/update-flutter-deps.md +0 -105
- package/lib/assets/.claude/commands/update-node-deps.md +0 -105
- package/lib/assets/.claude/commands/update-rust-deps.md +0 -107
- package/lib/assets/.claude/scripts/auto-comment.sh +0 -16
- package/lib/assets/.claude/scripts/check-ai-commit.sh +0 -20
- package/lib/assets/.claude/scripts/check-continue.sh +0 -97
- package/lib/assets/.claude/scripts/check-locales.sh +0 -1080
- package/lib/assets/.claude/scripts/check-project-plan.sh +0 -25
- package/lib/assets/.claude/scripts/debug-hook.sh +0 -7
- package/lib/assets/.claude/scripts/deny-check.sh +0 -69
- package/lib/assets/.claude/scripts/install.sh +0 -174
- package/lib/assets/.claude/scripts/ja-space-exclusions.json +0 -18
- package/lib/assets/.claude/scripts/ja-space-format.sh +0 -45
- package/lib/assets/.claude/scripts/preserve-file-permissions.sh +0 -83
- package/lib/assets/.claude/scripts/statusline.sh +0 -153
- /package/lib/assets/{app → .claude/agents/roles}/.gitkeep +0 -0
|
@@ -1,1129 +0,0 @@
|
|
|
1
|
-
## Semantic Commit
|
|
2
|
-
|
|
3
|
-
大きな変更を意味のある最小単位に分割して、セマンティックなコミットメッセージと共に順次コミットします。外部ツールに依存せず、git 標準コマンドのみを使用します。
|
|
4
|
-
|
|
5
|
-
### 使い方
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
/semantic-commit [オプション]
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
### オプション
|
|
12
|
-
|
|
13
|
-
- `--dry-run` : 実際のコミットは行わず、提案されるコミット分割のみを表示
|
|
14
|
-
- `--lang <言語>` : コミットメッセージの言語を強制指定(en, ja)
|
|
15
|
-
- `--max-commits <数>` : 最大コミット数を指定(デフォルト: 10)
|
|
16
|
-
|
|
17
|
-
### 基本例
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
# 現在の変更を分析して、論理的な単位でコミット
|
|
21
|
-
/semantic-commit
|
|
22
|
-
|
|
23
|
-
# 分割案のみを確認(実際のコミットなし)
|
|
24
|
-
/semantic-commit --dry-run
|
|
25
|
-
|
|
26
|
-
# 英語でコミットメッセージを生成
|
|
27
|
-
/semantic-commit --lang en
|
|
28
|
-
|
|
29
|
-
# 日本語でコミットメッセージを生成
|
|
30
|
-
/semantic-commit --lang ja
|
|
31
|
-
|
|
32
|
-
# 最大 5 個のコミットに分割
|
|
33
|
-
/semantic-commit --max-commits 5
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### 動作フロー
|
|
37
|
-
|
|
38
|
-
1. **変更分析**: `git diff HEAD` で全変更を取得
|
|
39
|
-
2. **ファイル分類**: 変更されたファイルを論理的にグループ化
|
|
40
|
-
3. **コミット提案**: 各グループに対してセマンティックなコミットメッセージを生成
|
|
41
|
-
4. **順次実行**: ユーザー確認後、各グループを順次コミット
|
|
42
|
-
|
|
43
|
-
### 変更分割の核心機能
|
|
44
|
-
|
|
45
|
-
#### 「大きな変更」の検出
|
|
46
|
-
|
|
47
|
-
以下の条件で大きな変更として検出:
|
|
48
|
-
|
|
49
|
-
1. **変更ファイル数**: 5 ファイル以上の変更
|
|
50
|
-
2. **変更行数**: 100 行以上の変更
|
|
51
|
-
3. **複数機能**: 2 つ以上の機能領域にまたがる変更
|
|
52
|
-
4. **混在パターン**: feat + fix + docs が混在
|
|
53
|
-
|
|
54
|
-
```bash
|
|
55
|
-
# 変更規模の分析
|
|
56
|
-
CHANGED_FILES=$(git diff HEAD --name-only | wc -l)
|
|
57
|
-
CHANGED_LINES=$(git diff HEAD --stat | tail -1 | grep -o '[0-9]\+ insertions\|[0-9]\+ deletions' | awk '{sum+=$1} END {print sum}')
|
|
58
|
-
|
|
59
|
-
if [ $CHANGED_FILES -ge 5 ] || [ $CHANGED_LINES -ge 100 ]; then
|
|
60
|
-
echo "大きな変更を検出: 分割を推奨"
|
|
61
|
-
fi
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
#### 「意味のある最小単位」への分割戦略
|
|
65
|
-
|
|
66
|
-
##### 1. 機能境界による分割
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
# ディレクトリ構造から機能単位を特定
|
|
70
|
-
git diff HEAD --name-only | cut -d'/' -f1-2 | sort | uniq
|
|
71
|
-
# → src/auth, src/api, components/ui など
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
##### 2. 変更種別による分離
|
|
75
|
-
|
|
76
|
-
```bash
|
|
77
|
-
# 新規ファイル vs 既存ファイル修正
|
|
78
|
-
git diff HEAD --name-status | grep '^A' # 新規ファイル
|
|
79
|
-
git diff HEAD --name-status | grep '^M' # 修正ファイル
|
|
80
|
-
git diff HEAD --name-status | grep '^D' # 削除ファイル
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
##### 3. 依存関係の分析
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
# インポート関係の変更を検出
|
|
87
|
-
git diff HEAD | grep -E '^[+-].*import|^[+-].*require' | \
|
|
88
|
-
cut -d' ' -f2- | sort | uniq
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
#### ファイル単位の詳細分析
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
# 変更されたファイル一覧を取得
|
|
95
|
-
git diff HEAD --name-only
|
|
96
|
-
|
|
97
|
-
# 各ファイルの変更内容を個別に分析
|
|
98
|
-
git diff HEAD -- <file>
|
|
99
|
-
|
|
100
|
-
# ファイルの変更タイプを判定
|
|
101
|
-
git diff HEAD --name-status | while read status file; do
|
|
102
|
-
case $status in
|
|
103
|
-
A) echo "$file: 新規作成" ;;
|
|
104
|
-
M) echo "$file: 修正" ;;
|
|
105
|
-
D) echo "$file: 削除" ;;
|
|
106
|
-
R*) echo "$file: リネーム" ;;
|
|
107
|
-
esac
|
|
108
|
-
done
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
#### 論理的グループ化の基準
|
|
112
|
-
|
|
113
|
-
1. **機能単位**: 同一機能に関連するファイル
|
|
114
|
-
- `src/auth/` 配下のファイル → 認証機能
|
|
115
|
-
- `components/` 配下のファイル → UI コンポーネント
|
|
116
|
-
|
|
117
|
-
2. **変更種別**: 同じ種類の変更
|
|
118
|
-
- テストファイルのみ → `test:`
|
|
119
|
-
- ドキュメントのみ → `docs:`
|
|
120
|
-
- 設定ファイルのみ → `chore:`
|
|
121
|
-
|
|
122
|
-
3. **依存関係**: 相互に関連するファイル
|
|
123
|
-
- モデル + マイグレーション
|
|
124
|
-
- コンポーネント + スタイル
|
|
125
|
-
|
|
126
|
-
4. **変更規模**: 適切なコミットサイズの維持
|
|
127
|
-
- 1 コミットあたり 10 ファイル以下
|
|
128
|
-
- 関連性の高いファイルをグループ化
|
|
129
|
-
|
|
130
|
-
### 出力例
|
|
131
|
-
|
|
132
|
-
```bash
|
|
133
|
-
$ /semantic-commit
|
|
134
|
-
|
|
135
|
-
変更分析中...
|
|
136
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
137
|
-
|
|
138
|
-
検出された変更:
|
|
139
|
-
• src/auth/login.ts (修正)
|
|
140
|
-
• src/auth/register.ts (新規)
|
|
141
|
-
• src/auth/types.ts (修正)
|
|
142
|
-
• tests/auth.test.ts (新規)
|
|
143
|
-
• docs/authentication.md (新規)
|
|
144
|
-
|
|
145
|
-
提案されるコミット分割:
|
|
146
|
-
|
|
147
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
148
|
-
コミット 1/3
|
|
149
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
150
|
-
メッセージ: feat: implement user registration and login system
|
|
151
|
-
含まれるファイル:
|
|
152
|
-
• src/auth/login.ts
|
|
153
|
-
• src/auth/register.ts
|
|
154
|
-
• src/auth/types.ts
|
|
155
|
-
|
|
156
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
157
|
-
コミット 2/3
|
|
158
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
159
|
-
メッセージ: test: add comprehensive tests for authentication system
|
|
160
|
-
含まれるファイル:
|
|
161
|
-
• tests/auth.test.ts
|
|
162
|
-
|
|
163
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
164
|
-
コミット 3/3
|
|
165
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
166
|
-
メッセージ: docs: add authentication system documentation
|
|
167
|
-
含まれるファイル:
|
|
168
|
-
• docs/authentication.md
|
|
169
|
-
|
|
170
|
-
この分割案でコミットを実行しますか? (y/n/edit):
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
### 実行時の選択肢
|
|
174
|
-
|
|
175
|
-
- `y` : 提案されたコミット分割で実行
|
|
176
|
-
- `n` : キャンセル
|
|
177
|
-
- `edit` : コミットメッセージを個別に編集
|
|
178
|
-
- `merge <番号 1> <番号 2>` : 指定したコミットをマージ
|
|
179
|
-
- `split <番号>` : 指定したコミットをさらに分割
|
|
180
|
-
|
|
181
|
-
### Dry Run モード
|
|
182
|
-
|
|
183
|
-
```bash
|
|
184
|
-
$ /semantic-commit --dry-run
|
|
185
|
-
|
|
186
|
-
変更分析中... (DRY RUN)
|
|
187
|
-
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
188
|
-
|
|
189
|
-
[コミット分割提案の表示]
|
|
190
|
-
|
|
191
|
-
ℹ️ DRY RUN モード: 実際のコミットは実行されません
|
|
192
|
-
💡 実行する場合は --dry-run オプションを除いて再実行してください
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### スマート分析機能
|
|
196
|
-
|
|
197
|
-
#### 1. プロジェクト構造の理解
|
|
198
|
-
|
|
199
|
-
- `package.json`, `Cargo.toml`, `pom.xml` などからプロジェクト種別を判定
|
|
200
|
-
- フォルダ構造から機能単位を推測
|
|
201
|
-
|
|
202
|
-
#### 2. 変更パターンの認識
|
|
203
|
-
|
|
204
|
-
```bash
|
|
205
|
-
# バグ修正パターンの検出
|
|
206
|
-
- "fix", "bug", "error" などのキーワード
|
|
207
|
-
- 例外処理の追加
|
|
208
|
-
- 条件分岐の修正
|
|
209
|
-
|
|
210
|
-
# 新機能パターンの検出
|
|
211
|
-
- 新ファイル作成
|
|
212
|
-
- 新メソッド追加
|
|
213
|
-
- API エンドポイント追加
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
#### 3. 依存関係の分析
|
|
217
|
-
|
|
218
|
-
- インポート文の変更
|
|
219
|
-
- 型定義の追加/修正
|
|
220
|
-
- 設定ファイルとの関連性
|
|
221
|
-
|
|
222
|
-
### 技術的実装
|
|
223
|
-
|
|
224
|
-
#### Git 標準コマンドによる順次コミット実装
|
|
225
|
-
|
|
226
|
-
##### 1. 前処理: 現在の状態を保存
|
|
227
|
-
|
|
228
|
-
```bash
|
|
229
|
-
# 未ステージの変更がある場合は一旦リセット
|
|
230
|
-
git reset HEAD
|
|
231
|
-
git status --porcelain > /tmp/original_state.txt
|
|
232
|
-
|
|
233
|
-
# 作業ブランチの確認
|
|
234
|
-
CURRENT_BRANCH=$(git branch --show-current)
|
|
235
|
-
echo "作業中のブランチ: $CURRENT_BRANCH"
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
##### 2. グループ別の順次コミット実行
|
|
239
|
-
|
|
240
|
-
```bash
|
|
241
|
-
# 分割計画の読み込み
|
|
242
|
-
while IFS= read -r commit_plan; do
|
|
243
|
-
group_num=$(echo "$commit_plan" | cut -d':' -f1)
|
|
244
|
-
files=$(echo "$commit_plan" | cut -d':' -f2- | tr ' ' '\n')
|
|
245
|
-
|
|
246
|
-
echo "=== コミット $group_num の実行 ==="
|
|
247
|
-
|
|
248
|
-
# 該当ファイルのみをステージング
|
|
249
|
-
echo "$files" | while read file; do
|
|
250
|
-
if [ -f "$file" ]; then
|
|
251
|
-
git add "$file"
|
|
252
|
-
echo "ステージング: $file"
|
|
253
|
-
fi
|
|
254
|
-
done
|
|
255
|
-
|
|
256
|
-
# ステージング状態の確認
|
|
257
|
-
staged_files=$(git diff --staged --name-only)
|
|
258
|
-
if [ -z "$staged_files" ]; then
|
|
259
|
-
echo "警告: ステージングされたファイルがありません"
|
|
260
|
-
continue
|
|
261
|
-
fi
|
|
262
|
-
|
|
263
|
-
# コミットメッセージの生成(LLM による分析)
|
|
264
|
-
commit_msg=$(generate_commit_message_for_staged_files)
|
|
265
|
-
|
|
266
|
-
# ユーザー確認
|
|
267
|
-
echo "提案コミットメッセージ: $commit_msg"
|
|
268
|
-
echo "ステージングされたファイル:"
|
|
269
|
-
echo "$staged_files"
|
|
270
|
-
read -p "このコミットを実行しますか? (y/n): " confirm
|
|
271
|
-
|
|
272
|
-
if [ "$confirm" = "y" ]; then
|
|
273
|
-
# コミット実行
|
|
274
|
-
git commit -m "$commit_msg"
|
|
275
|
-
echo "✅ コミット $group_num 完了"
|
|
276
|
-
else
|
|
277
|
-
# ステージングを取り消し
|
|
278
|
-
git reset HEAD
|
|
279
|
-
echo "❌ コミット $group_num をスキップ"
|
|
280
|
-
fi
|
|
281
|
-
|
|
282
|
-
done < /tmp/commit_plan.txt
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
##### 3. エラーハンドリングとロールバック
|
|
286
|
-
|
|
287
|
-
```bash
|
|
288
|
-
# プリコミットフック失敗時の処理
|
|
289
|
-
commit_with_retry() {
|
|
290
|
-
local commit_msg="$1"
|
|
291
|
-
local max_retries=2
|
|
292
|
-
local retry_count=0
|
|
293
|
-
|
|
294
|
-
while [ $retry_count -lt $max_retries ]; do
|
|
295
|
-
if git commit -m "$commit_msg"; then
|
|
296
|
-
echo "✅ コミット成功"
|
|
297
|
-
return 0
|
|
298
|
-
else
|
|
299
|
-
echo "❌ コミット失敗 (試行 $((retry_count + 1))/$max_retries)"
|
|
300
|
-
|
|
301
|
-
# プリコミットフックによる自動修正を取り込み
|
|
302
|
-
if git diff --staged --quiet; then
|
|
303
|
-
echo "プリコミットフックにより変更が自動修正されました"
|
|
304
|
-
git add -u
|
|
305
|
-
fi
|
|
306
|
-
|
|
307
|
-
retry_count=$((retry_count + 1))
|
|
308
|
-
fi
|
|
309
|
-
done
|
|
310
|
-
|
|
311
|
-
echo "❌ コミットに失敗しました。手動で確認してください。"
|
|
312
|
-
return 1
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
# 中断からの復旧
|
|
316
|
-
resume_from_failure() {
|
|
317
|
-
echo "中断されたコミット処理を検出しました"
|
|
318
|
-
echo "現在のステージング状態:"
|
|
319
|
-
git status --porcelain
|
|
320
|
-
|
|
321
|
-
read -p "処理を続行しますか? (y/n): " resume
|
|
322
|
-
if [ "$resume" = "y" ]; then
|
|
323
|
-
# 最後のコミット位置から再開
|
|
324
|
-
last_commit=$(git log --oneline -1 --pretty=format:"%s")
|
|
325
|
-
echo "最後のコミット: $last_commit"
|
|
326
|
-
else
|
|
327
|
-
# 完全リセット
|
|
328
|
-
git reset HEAD
|
|
329
|
-
echo "処理をリセットしました"
|
|
330
|
-
fi
|
|
331
|
-
}
|
|
332
|
-
```
|
|
333
|
-
|
|
334
|
-
##### 4. 完了後の検証
|
|
335
|
-
|
|
336
|
-
```bash
|
|
337
|
-
# 全変更がコミットされたかの確認
|
|
338
|
-
remaining_changes=$(git status --porcelain | wc -l)
|
|
339
|
-
if [ $remaining_changes -eq 0 ]; then
|
|
340
|
-
echo "✅ すべての変更がコミットされました"
|
|
341
|
-
else
|
|
342
|
-
echo "⚠️ 未コミットの変更が残っています:"
|
|
343
|
-
git status --short
|
|
344
|
-
fi
|
|
345
|
-
|
|
346
|
-
# コミット履歴の表示
|
|
347
|
-
echo "作成されたコミット:"
|
|
348
|
-
git log --oneline -n 10 --graph
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
##### 5. 自動プッシュの抑制
|
|
352
|
-
|
|
353
|
-
```bash
|
|
354
|
-
# 注意: 自動プッシュは行わない
|
|
355
|
-
echo "📝 注意: 自動プッシュは実行されません"
|
|
356
|
-
echo "必要に応じて以下のコマンドでプッシュしてください:"
|
|
357
|
-
echo " git push origin $CURRENT_BRANCH"
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
#### 分割アルゴリズムの詳細
|
|
361
|
-
|
|
362
|
-
##### ステップ 1: 初期分析
|
|
363
|
-
|
|
364
|
-
```bash
|
|
365
|
-
# 全変更ファイルの取得と分類
|
|
366
|
-
git diff HEAD --name-status | while read status file; do
|
|
367
|
-
echo "$status:$file"
|
|
368
|
-
done > /tmp/changes.txt
|
|
369
|
-
|
|
370
|
-
# 機能ディレクトリ別の変更統計
|
|
371
|
-
git diff HEAD --name-only | cut -d'/' -f1-2 | sort | uniq -c
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
##### ステップ 2: 機能境界による初期グループ化
|
|
375
|
-
|
|
376
|
-
```bash
|
|
377
|
-
# ディレクトリベースのグループ化
|
|
378
|
-
GROUPS=$(git diff HEAD --name-only | cut -d'/' -f1-2 | sort | uniq)
|
|
379
|
-
for group in $GROUPS; do
|
|
380
|
-
echo "=== グループ: $group ==="
|
|
381
|
-
git diff HEAD --name-only | grep "^$group" | head -10
|
|
382
|
-
done
|
|
383
|
-
```
|
|
384
|
-
|
|
385
|
-
##### ステップ 3: 変更内容の類似性分析
|
|
386
|
-
|
|
387
|
-
```bash
|
|
388
|
-
# 各ファイルの変更タイプを分析
|
|
389
|
-
git diff HEAD --name-only | while read file; do
|
|
390
|
-
# 新規関数/クラス追加の検出
|
|
391
|
-
NEW_FUNCTIONS=$(git diff HEAD -- "$file" | grep -c '^+.*function\|^+.*class\|^+.*def ')
|
|
392
|
-
|
|
393
|
-
# バグ修正パターンの検出
|
|
394
|
-
BUG_FIXES=$(git diff HEAD -- "$file" | grep -c '^+.*fix\|^+.*bug\|^-.*error')
|
|
395
|
-
|
|
396
|
-
# テストファイルかの判定
|
|
397
|
-
if [[ "$file" =~ test|spec ]]; then
|
|
398
|
-
echo "$file: TEST"
|
|
399
|
-
elif [ $NEW_FUNCTIONS -gt 0 ]; then
|
|
400
|
-
echo "$file: FEAT"
|
|
401
|
-
elif [ $BUG_FIXES -gt 0 ]; then
|
|
402
|
-
echo "$file: FIX"
|
|
403
|
-
else
|
|
404
|
-
echo "$file: REFACTOR"
|
|
405
|
-
fi
|
|
406
|
-
done
|
|
407
|
-
```
|
|
408
|
-
|
|
409
|
-
##### ステップ 4: 依存関係による調整
|
|
410
|
-
|
|
411
|
-
```bash
|
|
412
|
-
# インポート関係の分析
|
|
413
|
-
git diff HEAD | grep -E '^[+-].*import|^[+-].*from.*import' | \
|
|
414
|
-
while read line; do
|
|
415
|
-
echo "$line" | sed 's/^[+-]//' | awk '{print $2}'
|
|
416
|
-
done | sort | uniq > /tmp/imports.txt
|
|
417
|
-
|
|
418
|
-
# 関連ファイルのグループ化
|
|
419
|
-
git diff HEAD --name-only | while read file; do
|
|
420
|
-
basename=$(basename "$file" .js .ts .py)
|
|
421
|
-
related=$(git diff HEAD --name-only | grep "$basename" | grep -v "^$file$")
|
|
422
|
-
if [ -n "$related" ]; then
|
|
423
|
-
echo "関連ファイル群: $file <-> $related"
|
|
424
|
-
fi
|
|
425
|
-
done
|
|
426
|
-
```
|
|
427
|
-
|
|
428
|
-
##### ステップ 5: コミットサイズの最適化
|
|
429
|
-
|
|
430
|
-
```bash
|
|
431
|
-
# グループサイズの調整
|
|
432
|
-
MAX_FILES_PER_COMMIT=8
|
|
433
|
-
current_group=1
|
|
434
|
-
file_count=0
|
|
435
|
-
|
|
436
|
-
git diff HEAD --name-only | while read file; do
|
|
437
|
-
if [ $file_count -ge $MAX_FILES_PER_COMMIT ]; then
|
|
438
|
-
current_group=$((current_group + 1))
|
|
439
|
-
file_count=0
|
|
440
|
-
fi
|
|
441
|
-
echo "コミット $current_group: $file"
|
|
442
|
-
file_count=$((file_count + 1))
|
|
443
|
-
done
|
|
444
|
-
```
|
|
445
|
-
|
|
446
|
-
##### ステップ 6: 最終グループ決定
|
|
447
|
-
|
|
448
|
-
```bash
|
|
449
|
-
# 分割結果の検証
|
|
450
|
-
for group in $(seq 1 $current_group); do
|
|
451
|
-
files=$(grep "コミット $group:" /tmp/commit_plan.txt | cut -d':' -f2-)
|
|
452
|
-
lines=$(echo "$files" | xargs git diff HEAD -- | wc -l)
|
|
453
|
-
echo "コミット $group: $(echo "$files" | wc -w) ファイル, $lines 行変更"
|
|
454
|
-
done
|
|
455
|
-
```
|
|
456
|
-
|
|
457
|
-
### Conventional Commits 準拠
|
|
458
|
-
|
|
459
|
-
#### 基本形式
|
|
460
|
-
|
|
461
|
-
```
|
|
462
|
-
<type>[optional scope]: <description>
|
|
463
|
-
|
|
464
|
-
[optional body]
|
|
465
|
-
|
|
466
|
-
[optional footer(s)]
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
#### 標準タイプ
|
|
470
|
-
|
|
471
|
-
**必須タイプ**:
|
|
472
|
-
|
|
473
|
-
- `feat`: 新機能(ユーザーに見える機能追加)
|
|
474
|
-
- `fix`: バグ修正
|
|
475
|
-
|
|
476
|
-
**任意タイプ**:
|
|
477
|
-
|
|
478
|
-
- `build`: ビルドシステムや外部依存関係の変更
|
|
479
|
-
- `chore`: その他の変更(リリースに影響しない)
|
|
480
|
-
- `ci`: CI 設定ファイルやスクリプトの変更
|
|
481
|
-
- `docs`: ドキュメントのみの変更
|
|
482
|
-
- `style`: コードの意味に影響しない変更(空白、フォーマット、セミコロンなど)
|
|
483
|
-
- `refactor`: バグ修正や機能追加を伴わないコード変更
|
|
484
|
-
- `perf`: パフォーマンス改善
|
|
485
|
-
- `test`: テストの追加や修正
|
|
486
|
-
|
|
487
|
-
#### スコープ(任意)
|
|
488
|
-
|
|
489
|
-
変更の影響範囲を示す:
|
|
490
|
-
|
|
491
|
-
```
|
|
492
|
-
feat(api): add user authentication endpoint
|
|
493
|
-
fix(ui): resolve button alignment issue
|
|
494
|
-
docs(readme): update installation instructions
|
|
495
|
-
```
|
|
496
|
-
|
|
497
|
-
#### Breaking Change
|
|
498
|
-
|
|
499
|
-
API の破壊的変更がある場合:
|
|
500
|
-
|
|
501
|
-
```
|
|
502
|
-
feat!: change user API response format
|
|
503
|
-
|
|
504
|
-
BREAKING CHANGE: user response now includes additional metadata
|
|
505
|
-
```
|
|
506
|
-
|
|
507
|
-
または
|
|
508
|
-
|
|
509
|
-
```
|
|
510
|
-
feat(api)!: change authentication flow
|
|
511
|
-
```
|
|
512
|
-
|
|
513
|
-
#### プロジェクト規約の自動検出
|
|
514
|
-
|
|
515
|
-
**重要**: プロジェクト独自の規約が存在する場合は、それを優先します。
|
|
516
|
-
|
|
517
|
-
##### 1. CommitLint 設定の確認
|
|
518
|
-
|
|
519
|
-
以下のファイルから設定を自動検出:
|
|
520
|
-
|
|
521
|
-
- `commitlint.config.js`
|
|
522
|
-
- `commitlint.config.mjs`
|
|
523
|
-
- `commitlint.config.cjs`
|
|
524
|
-
- `commitlint.config.ts`
|
|
525
|
-
- `.commitlintrc.js`
|
|
526
|
-
- `.commitlintrc.json`
|
|
527
|
-
- `.commitlintrc.yml`
|
|
528
|
-
- `.commitlintrc.yaml`
|
|
529
|
-
- `package.json` の `commitlint` セクション
|
|
530
|
-
|
|
531
|
-
```bash
|
|
532
|
-
# 設定ファイル例の確認
|
|
533
|
-
cat commitlint.config.mjs
|
|
534
|
-
cat .commitlintrc.json
|
|
535
|
-
grep -A 10 '"commitlint"' package.json
|
|
536
|
-
```
|
|
537
|
-
|
|
538
|
-
##### 2. カスタムタイプの検出
|
|
539
|
-
|
|
540
|
-
プロジェクト独自のタイプ例:
|
|
541
|
-
|
|
542
|
-
```javascript
|
|
543
|
-
// commitlint.config.mjs
|
|
544
|
-
export default {
|
|
545
|
-
extends: ['@commitlint/config-conventional'],
|
|
546
|
-
rules: {
|
|
547
|
-
'type-enum': [
|
|
548
|
-
2,
|
|
549
|
-
'always',
|
|
550
|
-
[
|
|
551
|
-
'feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore',
|
|
552
|
-
'wip', // 作業中
|
|
553
|
-
'hotfix', // 緊急修正
|
|
554
|
-
'release', // リリース
|
|
555
|
-
'deps', // 依存関係更新
|
|
556
|
-
'config' // 設定変更
|
|
557
|
-
]
|
|
558
|
-
]
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
```
|
|
562
|
-
|
|
563
|
-
##### 3. 言語設定の検出
|
|
564
|
-
|
|
565
|
-
```javascript
|
|
566
|
-
// プロジェクトが日本語メッセージを使用する場合
|
|
567
|
-
export default {
|
|
568
|
-
rules: {
|
|
569
|
-
'subject-case': [0], // 日本語対応のため無効化
|
|
570
|
-
'subject-max-length': [2, 'always', 72] // 日本語は文字数制限を調整
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
```
|
|
574
|
-
|
|
575
|
-
#### 自動分析の流れ
|
|
576
|
-
|
|
577
|
-
1. **設定ファイル検索**
|
|
578
|
-
|
|
579
|
-
```bash
|
|
580
|
-
find . -name "commitlint.config.*" -o -name ".commitlintrc.*" | head -1
|
|
581
|
-
```
|
|
582
|
-
|
|
583
|
-
2. **既存コミット分析**
|
|
584
|
-
|
|
585
|
-
```bash
|
|
586
|
-
git log --oneline -50 --pretty=format:"%s"
|
|
587
|
-
```
|
|
588
|
-
|
|
589
|
-
3. **使用タイプ統計**
|
|
590
|
-
|
|
591
|
-
```bash
|
|
592
|
-
git log --oneline -100 --pretty=format:"%s" | \
|
|
593
|
-
grep -oE '^[a-z]+(\([^)]+\))?' | \
|
|
594
|
-
sort | uniq -c | sort -nr
|
|
595
|
-
```
|
|
596
|
-
|
|
597
|
-
#### プロジェクト規約の例
|
|
598
|
-
|
|
599
|
-
##### Angular スタイル
|
|
600
|
-
|
|
601
|
-
```
|
|
602
|
-
feat(scope): add new feature
|
|
603
|
-
fix(scope): fix bug
|
|
604
|
-
docs(scope): update documentation
|
|
605
|
-
```
|
|
606
|
-
|
|
607
|
-
##### Gitmoji 併用スタイル
|
|
608
|
-
|
|
609
|
-
```
|
|
610
|
-
✨ feat: add user registration
|
|
611
|
-
🐛 fix: resolve login issue
|
|
612
|
-
📚 docs: update API docs
|
|
613
|
-
```
|
|
614
|
-
|
|
615
|
-
##### 日本語プロジェクト
|
|
616
|
-
|
|
617
|
-
```
|
|
618
|
-
feat: ユーザー登録機能を追加
|
|
619
|
-
fix: ログイン処理のバグを修正
|
|
620
|
-
docs: API ドキュメントを更新
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
### 言語判定
|
|
624
|
-
|
|
625
|
-
このコマンドで完結する言語判定ロジック:
|
|
626
|
-
|
|
627
|
-
1. **CommitLint 設定**から言語設定を確認
|
|
628
|
-
|
|
629
|
-
```bash
|
|
630
|
-
# subject-case ルールが無効化されている場合は日本語と判定
|
|
631
|
-
grep -E '"subject-case".*\[0\]|subject-case.*0' commitlint.config.*
|
|
632
|
-
```
|
|
633
|
-
|
|
634
|
-
2. **git log 分析**による自動判定
|
|
635
|
-
|
|
636
|
-
```bash
|
|
637
|
-
# 最近 20 コミットの言語を分析
|
|
638
|
-
git log --oneline -20 --pretty=format:"%s" | \
|
|
639
|
-
grep -E '^[あ-ん]|[ア-ン]|[一-龯]' | wc -l
|
|
640
|
-
# 50% 以上が日本語なら日本語モード
|
|
641
|
-
```
|
|
642
|
-
|
|
643
|
-
3. **プロジェクトファイル**の言語設定
|
|
644
|
-
|
|
645
|
-
```bash
|
|
646
|
-
# README.md の言語確認
|
|
647
|
-
head -10 README.md | grep -E '^[あ-ん]|[ア-ン]|[一-龯]' | wc -l
|
|
648
|
-
|
|
649
|
-
# package.json の description 確認
|
|
650
|
-
grep -E '"description".*[あ-ん]|[ア-ン]|[一-龯]' package.json
|
|
651
|
-
```
|
|
652
|
-
|
|
653
|
-
4. **変更ファイル内**のコメント・文字列分析
|
|
654
|
-
|
|
655
|
-
```bash
|
|
656
|
-
# 変更されたファイルのコメント言語を確認
|
|
657
|
-
git diff HEAD | grep -E '^[+-].*//.*[あ-ん]|[ア-ン]|[一-龯]' | wc -l
|
|
658
|
-
```
|
|
659
|
-
|
|
660
|
-
#### 判定アルゴリズム
|
|
661
|
-
|
|
662
|
-
```bash
|
|
663
|
-
# 言語判定スコア計算
|
|
664
|
-
JAPANESE_SCORE=0
|
|
665
|
-
|
|
666
|
-
# 1. CommitLint 設定 (+3 点)
|
|
667
|
-
if grep -q '"subject-case".*\[0\]' commitlint.config.* 2>/dev/null; then
|
|
668
|
-
JAPANESE_SCORE=$((JAPANESE_SCORE + 3))
|
|
669
|
-
fi
|
|
670
|
-
|
|
671
|
-
# 2. git log 分析 (最大+2 点)
|
|
672
|
-
JAPANESE_COMMITS=$(git log --oneline -20 --pretty=format:"%s" | \
|
|
673
|
-
grep -cE '[あ-ん]|[ア-ン]|[一-龯]' 2>/dev/null || echo 0)
|
|
674
|
-
if [ $JAPANESE_COMMITS -gt 10 ]; then
|
|
675
|
-
JAPANESE_SCORE=$((JAPANESE_SCORE + 2))
|
|
676
|
-
elif [ $JAPANESE_COMMITS -gt 5 ]; then
|
|
677
|
-
JAPANESE_SCORE=$((JAPANESE_SCORE + 1))
|
|
678
|
-
fi
|
|
679
|
-
|
|
680
|
-
# 3. README.md 確認 (+1 点)
|
|
681
|
-
if head -5 README.md 2>/dev/null | grep -qE '[あ-ん]|[ア-ン]|[一-龯]'; then
|
|
682
|
-
JAPANESE_SCORE=$((JAPANESE_SCORE + 1))
|
|
683
|
-
fi
|
|
684
|
-
|
|
685
|
-
# 4. 変更ファイル内容確認 (+1 点)
|
|
686
|
-
if git diff HEAD 2>/dev/null | grep -qE '^[+-].*[あ-ん]|[ア-ン]|[一-龯]'; then
|
|
687
|
-
JAPANESE_SCORE=$((JAPANESE_SCORE + 1))
|
|
688
|
-
fi
|
|
689
|
-
|
|
690
|
-
# 判定: 3 点以上で日本語モード
|
|
691
|
-
if [ $JAPANESE_SCORE -ge 3 ]; then
|
|
692
|
-
LANGUAGE="ja"
|
|
693
|
-
else
|
|
694
|
-
LANGUAGE="en"
|
|
695
|
-
fi
|
|
696
|
-
```
|
|
697
|
-
|
|
698
|
-
### 設定ファイル自動読み込み
|
|
699
|
-
|
|
700
|
-
#### 実行時の動作
|
|
701
|
-
|
|
702
|
-
コマンド実行時に以下の順序で設定を確認:
|
|
703
|
-
|
|
704
|
-
1. **CommitLint 設定ファイルの検索**
|
|
705
|
-
|
|
706
|
-
```bash
|
|
707
|
-
# 以下の順序で検索し、最初に見つかったファイルを使用
|
|
708
|
-
commitlint.config.mjs
|
|
709
|
-
commitlint.config.js
|
|
710
|
-
commitlint.config.cjs
|
|
711
|
-
commitlint.config.ts
|
|
712
|
-
.commitlintrc.js
|
|
713
|
-
.commitlintrc.json
|
|
714
|
-
.commitlintrc.yml
|
|
715
|
-
.commitlintrc.yaml
|
|
716
|
-
package.json (commitlint セクション)
|
|
717
|
-
```
|
|
718
|
-
|
|
719
|
-
2. **設定内容の解析**
|
|
720
|
-
- 使用可能なタイプの一覧を抽出
|
|
721
|
-
- スコープの制限があるかを確認
|
|
722
|
-
- メッセージ長制限の取得
|
|
723
|
-
- 言語設定の確認
|
|
724
|
-
|
|
725
|
-
3. **既存コミット履歴の分析**
|
|
726
|
-
|
|
727
|
-
```bash
|
|
728
|
-
# 最近のコミットから使用パターンを学習
|
|
729
|
-
git log --oneline -100 --pretty=format:"%s" | \
|
|
730
|
-
head -20
|
|
731
|
-
```
|
|
732
|
-
|
|
733
|
-
#### 設定例の分析
|
|
734
|
-
|
|
735
|
-
**標準的な commitlint.config.mjs**:
|
|
736
|
-
|
|
737
|
-
```javascript
|
|
738
|
-
export default {
|
|
739
|
-
extends: ['@commitlint/config-conventional'],
|
|
740
|
-
rules: {
|
|
741
|
-
'type-enum': [
|
|
742
|
-
2,
|
|
743
|
-
'always',
|
|
744
|
-
['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'chore']
|
|
745
|
-
],
|
|
746
|
-
'scope-enum': [
|
|
747
|
-
2,
|
|
748
|
-
'always',
|
|
749
|
-
['api', 'ui', 'core', 'auth', 'db']
|
|
750
|
-
]
|
|
751
|
-
}
|
|
752
|
-
}
|
|
753
|
-
```
|
|
754
|
-
|
|
755
|
-
**日本語対応の設定**:
|
|
756
|
-
|
|
757
|
-
```javascript
|
|
758
|
-
export default {
|
|
759
|
-
extends: ['@commitlint/config-conventional'],
|
|
760
|
-
rules: {
|
|
761
|
-
'subject-case': [0], // 日本語のため無効化
|
|
762
|
-
'subject-max-length': [2, 'always', 72],
|
|
763
|
-
'type-enum': [
|
|
764
|
-
2,
|
|
765
|
-
'always',
|
|
766
|
-
['feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore']
|
|
767
|
-
]
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
```
|
|
771
|
-
|
|
772
|
-
**カスタムタイプを含む設定**:
|
|
773
|
-
|
|
774
|
-
```javascript
|
|
775
|
-
export default {
|
|
776
|
-
extends: ['@commitlint/config-conventional'],
|
|
777
|
-
rules: {
|
|
778
|
-
'type-enum': [
|
|
779
|
-
2,
|
|
780
|
-
'always',
|
|
781
|
-
[
|
|
782
|
-
'feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore',
|
|
783
|
-
'wip', // Work in Progress
|
|
784
|
-
'hotfix', // 緊急修正
|
|
785
|
-
'release', // リリース準備
|
|
786
|
-
'deps', // 依存関係更新
|
|
787
|
-
'config' // 設定変更
|
|
788
|
-
]
|
|
789
|
-
]
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
```
|
|
793
|
-
|
|
794
|
-
#### フォールバック動作
|
|
795
|
-
|
|
796
|
-
設定ファイルが見つからない場合:
|
|
797
|
-
|
|
798
|
-
1. **git log 分析**による自動推測
|
|
799
|
-
|
|
800
|
-
```bash
|
|
801
|
-
# 最近 100 コミットからタイプを抽出
|
|
802
|
-
git log --oneline -100 --pretty=format:"%s" | \
|
|
803
|
-
grep -oE '^[a-z]+(\([^)]+\))?' | \
|
|
804
|
-
sort | uniq -c | sort -nr
|
|
805
|
-
```
|
|
806
|
-
|
|
807
|
-
2. **Conventional Commits 標準**をデフォルト使用
|
|
808
|
-
|
|
809
|
-
```
|
|
810
|
-
feat, fix, docs, style, refactor, perf, test, chore, build, ci
|
|
811
|
-
```
|
|
812
|
-
|
|
813
|
-
3. **言語判定**
|
|
814
|
-
- 日本語コミットが 50% 以上 → 日本語モード
|
|
815
|
-
- その他 → 英語モード
|
|
816
|
-
|
|
817
|
-
### 前提条件
|
|
818
|
-
|
|
819
|
-
- Git リポジトリ内で実行
|
|
820
|
-
- 未コミットの変更が存在すること
|
|
821
|
-
- ステージングされた変更は一旦リセットされます
|
|
822
|
-
|
|
823
|
-
### 注意事項
|
|
824
|
-
|
|
825
|
-
- **自動プッシュなし**: コミット後の `git push` は手動実行
|
|
826
|
-
- **ブランチ作成なし**: 現在のブランチでコミット
|
|
827
|
-
- **バックアップ推奨**: 重要な変更前には `git stash` でバックアップ
|
|
828
|
-
|
|
829
|
-
### プロジェクト規約の優先度
|
|
830
|
-
|
|
831
|
-
コミットメッセージ生成時の優先度:
|
|
832
|
-
|
|
833
|
-
1. **CommitLint 設定** (最優先)
|
|
834
|
-
- `commitlint.config.*` ファイルの設定
|
|
835
|
-
- カスタムタイプやスコープの制限
|
|
836
|
-
- メッセージ長やケースの制限
|
|
837
|
-
|
|
838
|
-
2. **既存コミット履歴** (第 2 優先)
|
|
839
|
-
- 実際に使用されているタイプの統計
|
|
840
|
-
- メッセージの言語(日本語/英語)
|
|
841
|
-
- スコープの使用パターン
|
|
842
|
-
|
|
843
|
-
3. **プロジェクト種別** (第 3 優先)
|
|
844
|
-
- `package.json` → Node.js プロジェクト
|
|
845
|
-
- `Cargo.toml` → Rust プロジェクト
|
|
846
|
-
- `pom.xml` → Java プロジェクト
|
|
847
|
-
|
|
848
|
-
4. **Conventional Commits 標準** (フォールバック)
|
|
849
|
-
- 設定が見つからない場合の標準動作
|
|
850
|
-
|
|
851
|
-
#### 規約検出の実例
|
|
852
|
-
|
|
853
|
-
**Monorepo での scope 自動検出**:
|
|
854
|
-
|
|
855
|
-
```bash
|
|
856
|
-
# packages/ フォルダから scope を推測
|
|
857
|
-
ls packages/ | head -10
|
|
858
|
-
# → api, ui, core, auth などを scope として提案
|
|
859
|
-
```
|
|
860
|
-
|
|
861
|
-
**フレームワーク固有の規約**:
|
|
862
|
-
|
|
863
|
-
```javascript
|
|
864
|
-
// Angular プロジェクトの場合
|
|
865
|
-
{
|
|
866
|
-
'scope-enum': [2, 'always', [
|
|
867
|
-
'animations', 'common', 'core', 'forms', 'http', 'platform-browser',
|
|
868
|
-
'platform-server', 'router', 'service-worker', 'upgrade'
|
|
869
|
-
]]
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
// React プロジェクトの場合
|
|
873
|
-
{
|
|
874
|
-
'scope-enum': [2, 'always', [
|
|
875
|
-
'components', 'hooks', 'utils', 'types', 'styles', 'api'
|
|
876
|
-
]]
|
|
877
|
-
}
|
|
878
|
-
```
|
|
879
|
-
|
|
880
|
-
**企業・チーム固有の規約**:
|
|
881
|
-
|
|
882
|
-
```javascript
|
|
883
|
-
// 日本の企業でよく見られるパターン
|
|
884
|
-
{
|
|
885
|
-
'type-enum': [2, 'always', [
|
|
886
|
-
'feat', 'fix', 'docs', 'style', 'refactor', 'test', 'chore',
|
|
887
|
-
'wip', // 作業中(プルリクエスト用)
|
|
888
|
-
'hotfix', // 緊急修正
|
|
889
|
-
'release' // リリース準備
|
|
890
|
-
]],
|
|
891
|
-
'subject-case': [0], // 日本語対応
|
|
892
|
-
'subject-max-length': [2, 'always', 72] // 日本語は長めに設定
|
|
893
|
-
}
|
|
894
|
-
```
|
|
895
|
-
|
|
896
|
-
### ベストプラクティス
|
|
897
|
-
|
|
898
|
-
1. **プロジェクト規約の尊重**: 既存の設定やパターンに従う
|
|
899
|
-
2. **小さな変更単位**: 1 つのコミットは 1 つの論理的変更
|
|
900
|
-
3. **明確なメッセージ**: 何を変更したかが明確
|
|
901
|
-
4. **関連性の重視**: 機能的に関連するファイルをグループ化
|
|
902
|
-
5. **テストの分離**: テストファイルは別コミットに
|
|
903
|
-
6. **設定ファイルの活用**: CommitLint を導入してチーム全体で規約を統一
|
|
904
|
-
|
|
905
|
-
### 実際の分割例(Before/After)
|
|
906
|
-
|
|
907
|
-
#### 例 1: 大規模な認証システム追加
|
|
908
|
-
|
|
909
|
-
**Before(1 つの巨大なコミット):**
|
|
910
|
-
|
|
911
|
-
```bash
|
|
912
|
-
# 変更されたファイル(15 ファイル、850 行変更)
|
|
913
|
-
src/auth/login.js # 新規作成
|
|
914
|
-
src/auth/register.js # 新規作成
|
|
915
|
-
src/auth/password.js # 新規作成
|
|
916
|
-
src/auth/types.js # 新規作成
|
|
917
|
-
src/api/auth-routes.js # 新規作成
|
|
918
|
-
src/middleware/auth.js # 新規作成
|
|
919
|
-
src/database/migrations/001_users.sql # 新規作成
|
|
920
|
-
src/database/models/user.js # 新規作成
|
|
921
|
-
tests/auth/login.test.js # 新規作成
|
|
922
|
-
tests/auth/register.test.js # 新規作成
|
|
923
|
-
tests/api/auth-routes.test.js # 新規作成
|
|
924
|
-
docs/authentication.md # 新規作成
|
|
925
|
-
package.json # 依存関係追加
|
|
926
|
-
README.md # 使用方法追加
|
|
927
|
-
.env.example # 環境変数例追加
|
|
928
|
-
|
|
929
|
-
# 従来の問題のあるコミット
|
|
930
|
-
feat: implement complete user authentication system with login, registration, password reset, API routes, database models, tests and documentation
|
|
931
|
-
```
|
|
932
|
-
|
|
933
|
-
**After(意味のある 5 つのコミットに分割):**
|
|
934
|
-
|
|
935
|
-
```bash
|
|
936
|
-
# コミット 1: データベース基盤
|
|
937
|
-
feat(db): add user model and authentication schema
|
|
938
|
-
|
|
939
|
-
含まれるファイル:
|
|
940
|
-
- src/database/migrations/001_users.sql
|
|
941
|
-
- src/database/models/user.js
|
|
942
|
-
- src/auth/types.js
|
|
943
|
-
|
|
944
|
-
理由: データベース構造は他の機能の基盤となるため最初にコミット
|
|
945
|
-
|
|
946
|
-
# コミット 2: 認証ロジック
|
|
947
|
-
feat(auth): implement core authentication functionality
|
|
948
|
-
|
|
949
|
-
含まれるファイル:
|
|
950
|
-
- src/auth/login.js
|
|
951
|
-
- src/auth/register.js
|
|
952
|
-
- src/auth/password.js
|
|
953
|
-
- src/middleware/auth.js
|
|
954
|
-
|
|
955
|
-
理由: 認証の核となるビジネスロジックを一括でコミット
|
|
956
|
-
|
|
957
|
-
# コミット 3: API エンドポイント
|
|
958
|
-
feat(api): add authentication API routes
|
|
959
|
-
|
|
960
|
-
含まれるファイル:
|
|
961
|
-
- src/api/auth-routes.js
|
|
962
|
-
|
|
963
|
-
理由: API レイヤーは認証ロジックに依存するため後でコミット
|
|
964
|
-
|
|
965
|
-
# コミット 4: 包括的なテスト
|
|
966
|
-
test(auth): add comprehensive authentication tests
|
|
967
|
-
|
|
968
|
-
含まれるファイル:
|
|
969
|
-
- tests/auth/login.test.js
|
|
970
|
-
- tests/auth/register.test.js
|
|
971
|
-
- tests/api/auth-routes.test.js
|
|
972
|
-
|
|
973
|
-
理由: 実装完了後にテストを一括追加
|
|
974
|
-
|
|
975
|
-
# コミット 5: 設定とドキュメント
|
|
976
|
-
docs(auth): add authentication documentation and configuration
|
|
977
|
-
|
|
978
|
-
含まれるファイル:
|
|
979
|
-
- docs/authentication.md
|
|
980
|
-
- package.json
|
|
981
|
-
- README.md
|
|
982
|
-
- .env.example
|
|
983
|
-
|
|
984
|
-
理由: ドキュメントと設定は最後にまとめてコミット
|
|
985
|
-
```
|
|
986
|
-
|
|
987
|
-
#### 例 2: バグ修正とリファクタリングの混在
|
|
988
|
-
|
|
989
|
-
**Before(混在した問題のあるコミット):**
|
|
990
|
-
|
|
991
|
-
```bash
|
|
992
|
-
# 変更されたファイル(8 ファイル、320 行変更)
|
|
993
|
-
src/user/service.js # バグ修正 + リファクタリング
|
|
994
|
-
src/user/validator.js # 新規作成(リファクタリング)
|
|
995
|
-
src/auth/middleware.js # バグ修正
|
|
996
|
-
src/api/user-routes.js # バグ修正 + エラーハンドリング改善
|
|
997
|
-
tests/user.test.js # テスト追加
|
|
998
|
-
tests/auth.test.js # バグ修正テスト追加
|
|
999
|
-
docs/user-api.md # ドキュメント更新
|
|
1000
|
-
package.json # 依存関係更新
|
|
1001
|
-
|
|
1002
|
-
# 問題のあるコミット
|
|
1003
|
-
fix: resolve user validation bugs and refactor validation logic with improved error handling
|
|
1004
|
-
```
|
|
1005
|
-
|
|
1006
|
-
**After(種別別に 3 つのコミットに分割):**
|
|
1007
|
-
|
|
1008
|
-
```bash
|
|
1009
|
-
# コミット 1: 緊急バグ修正
|
|
1010
|
-
fix: resolve user validation and authentication bugs
|
|
1011
|
-
|
|
1012
|
-
含まれるファイル:
|
|
1013
|
-
- src/user/service.js(バグ修正部分のみ)
|
|
1014
|
-
- src/auth/middleware.js
|
|
1015
|
-
- tests/auth.test.js(バグ修正テストのみ)
|
|
1016
|
-
|
|
1017
|
-
理由: 本番環境に影響するバグは最優先で修正
|
|
1018
|
-
|
|
1019
|
-
# コミット 2: バリデーションロジックのリファクタリング
|
|
1020
|
-
refactor: extract and improve user validation logic
|
|
1021
|
-
|
|
1022
|
-
含まれるファイル:
|
|
1023
|
-
- src/user/service.js(リファクタリング部分)
|
|
1024
|
-
- src/user/validator.js
|
|
1025
|
-
- src/api/user-routes.js
|
|
1026
|
-
- tests/user.test.js
|
|
1027
|
-
|
|
1028
|
-
理由: 構造改善は機能単位でまとめてコミット
|
|
1029
|
-
|
|
1030
|
-
# コミット 3: ドキュメントと依存関係更新
|
|
1031
|
-
chore: update documentation and dependencies
|
|
1032
|
-
|
|
1033
|
-
含まれるファイル:
|
|
1034
|
-
- docs/user-api.md
|
|
1035
|
-
- package.json
|
|
1036
|
-
|
|
1037
|
-
理由: 開発環境の整備は最後にまとめてコミット
|
|
1038
|
-
```
|
|
1039
|
-
|
|
1040
|
-
#### 例 3: 複数機能の同時開発
|
|
1041
|
-
|
|
1042
|
-
**Before(機能横断の巨大コミット):**
|
|
1043
|
-
|
|
1044
|
-
```bash
|
|
1045
|
-
# 変更されたファイル(12 ファイル、600 行変更)
|
|
1046
|
-
src/user/profile.js # 新機能 A
|
|
1047
|
-
src/user/avatar.js # 新機能 A
|
|
1048
|
-
src/notification/email.js # 新機能 B
|
|
1049
|
-
src/notification/sms.js # 新機能 B
|
|
1050
|
-
src/api/profile-routes.js # 新機能 A 用 API
|
|
1051
|
-
src/api/notification-routes.js # 新機能 B 用 API
|
|
1052
|
-
src/dashboard/widgets.js # 新機能 C
|
|
1053
|
-
src/dashboard/charts.js # 新機能 C
|
|
1054
|
-
tests/profile.test.js # 新機能 A 用テスト
|
|
1055
|
-
tests/notification.test.js # 新機能 B 用テスト
|
|
1056
|
-
tests/dashboard.test.js # 新機能 C 用テスト
|
|
1057
|
-
package.json # 全機能の依存関係
|
|
1058
|
-
|
|
1059
|
-
# 問題のあるコミット
|
|
1060
|
-
feat: add user profile management, notification system and dashboard widgets
|
|
1061
|
-
```
|
|
1062
|
-
|
|
1063
|
-
**After(機能別に 4 つのコミットに分割):**
|
|
1064
|
-
|
|
1065
|
-
```bash
|
|
1066
|
-
# コミット 1: ユーザープロフィール機能
|
|
1067
|
-
feat(profile): add user profile management
|
|
1068
|
-
|
|
1069
|
-
含まれるファイル:
|
|
1070
|
-
- src/user/profile.js
|
|
1071
|
-
- src/user/avatar.js
|
|
1072
|
-
- src/api/profile-routes.js
|
|
1073
|
-
- tests/profile.test.js
|
|
1074
|
-
|
|
1075
|
-
理由: プロフィール機能は独立した機能単位
|
|
1076
|
-
|
|
1077
|
-
# コミット 2: 通知システム
|
|
1078
|
-
feat(notification): implement email and SMS notifications
|
|
1079
|
-
|
|
1080
|
-
含まれるファイル:
|
|
1081
|
-
- src/notification/email.js
|
|
1082
|
-
- src/notification/sms.js
|
|
1083
|
-
- src/api/notification-routes.js
|
|
1084
|
-
- tests/notification.test.js
|
|
1085
|
-
|
|
1086
|
-
理由: 通知機能は独立した機能単位
|
|
1087
|
-
|
|
1088
|
-
# コミット 3: ダッシュボードウィジェット
|
|
1089
|
-
feat(dashboard): add interactive widgets and charts
|
|
1090
|
-
|
|
1091
|
-
含まれるファイル:
|
|
1092
|
-
- src/dashboard/widgets.js
|
|
1093
|
-
- src/dashboard/charts.js
|
|
1094
|
-
- tests/dashboard.test.js
|
|
1095
|
-
|
|
1096
|
-
理由: ダッシュボード機能は独立した機能単位
|
|
1097
|
-
|
|
1098
|
-
# コミット 4: 依存関係とインフラ更新
|
|
1099
|
-
chore: update dependencies for new features
|
|
1100
|
-
|
|
1101
|
-
含まれるファイル:
|
|
1102
|
-
- package.json
|
|
1103
|
-
|
|
1104
|
-
理由: 共通の依存関係更新は最後にまとめて
|
|
1105
|
-
```
|
|
1106
|
-
|
|
1107
|
-
### 分割効果の比較
|
|
1108
|
-
|
|
1109
|
-
| 項目 | Before(巨大コミット) | After(適切な分割) |
|
|
1110
|
-
|------|---------------------|-------------------|
|
|
1111
|
-
| **レビュー性** | ❌ 非常に困難 | ✅ 各コミットが小さくレビュー可能 |
|
|
1112
|
-
| **バグ追跡** | ❌ 問題箇所の特定が困難 | ✅ 問題のあるコミットを即座に特定 |
|
|
1113
|
-
| **リバート** | ❌ 全体をリバートする必要 | ✅ 問題部分のみをピンポイントでリバート |
|
|
1114
|
-
| **並行開発** | ❌ コンフリクトが発生しやすい | ✅ 機能別でマージが容易 |
|
|
1115
|
-
| **デプロイ** | ❌ 全機能を一括デプロイ | ✅ 段階的なデプロイが可能 |
|
|
1116
|
-
|
|
1117
|
-
### トラブルシューティング
|
|
1118
|
-
|
|
1119
|
-
#### コミット失敗時
|
|
1120
|
-
|
|
1121
|
-
- プリコミットフックの確認
|
|
1122
|
-
- 依存関係の解決
|
|
1123
|
-
- 個別ファイルでの再試行
|
|
1124
|
-
|
|
1125
|
-
#### 分割が適切でない場合
|
|
1126
|
-
|
|
1127
|
-
- `--max-commits` オプションで調整
|
|
1128
|
-
- 手動での `edit` モード使用
|
|
1129
|
-
- より細かい単位での再実行
|