Conversation
- 数値プレフィックス形式(001-feature-name)を廃止 - Conventional Commit形式(type/description)のみを許可 - 有効なtype: feat, fix, refactor, docs, chore, style, test, perf, ci, build - 既存のフィーチャーブランチにいる場合は新規ブランチ作成をスキップ - 既存のspec.mdがある場合はテンプレート上書きをスキップ Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
There was a problem hiding this comment.
Pull request overview
このPRは、ブランチ命名規則を数値プレフィックス形式(001-feature-name)からConventional Commit形式(type/description)に変更するリファクタリングです。
主な変更点:
--numberオプションを--typeオプションに置き換え、10種類のConventional Commitタイプをサポート- 既存のフィーチャーブランチにいる場合の自動検出とブランチ作成スキップ機能を追加(worktree対応)
- 既存の
spec.mdファイルがある場合のテンプレート上書き防止機能を追加
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
.specify/scripts/bash/create-new-feature.sh |
--numberオプションを--typeオプションに変更し、Conventional Commit形式のブランチ作成ロジックを実装。既存フィーチャーブランチ検出とspec.md上書き防止機能を追加 |
.specify/scripts/bash/common.sh |
check_feature_branch()とfind_feature_dir_by_prefix()をConventional Commit形式に対応するよう更新。ブランチ名バリデーションとディレクトリ名変換ロジックを修正 |
| if [[ "$branch_name" =~ ^(feat|fix|refactor|docs|chore|style|test|perf|ci|build)/ ]]; then | ||
| local dir_name="${branch_name//\//-}" | ||
| echo "$specs_dir/$dir_name" | ||
| return | ||
| fi | ||
|
|
||
| local prefix="${BASH_REMATCH[1]}" | ||
|
|
||
| # Search for directories in specs/ that start with this prefix | ||
| local matches=() | ||
| if [[ -d "$specs_dir" ]]; then | ||
| for dir in "$specs_dir"/"$prefix"-*; do | ||
| if [[ -d "$dir" ]]; then | ||
| matches+=("$(basename "$dir")") | ||
| fi | ||
| done | ||
| fi | ||
|
|
||
| # Handle results | ||
| if [[ ${#matches[@]} -eq 0 ]]; then | ||
| # No match found - return the branch name path (will fail later with clear error) | ||
| echo "$specs_dir/$branch_name" | ||
| elif [[ ${#matches[@]} -eq 1 ]]; then | ||
| # Exactly one match - perfect! | ||
| echo "$specs_dir/${matches[0]}" | ||
| else | ||
| # Multiple matches - this shouldn't happen with proper naming convention | ||
| echo "ERROR: Multiple spec directories found with prefix '$prefix': ${matches[*]}" >&2 | ||
| echo "Please ensure only one spec directory exists per numeric prefix." >&2 | ||
| echo "$specs_dir/$branch_name" # Return something to avoid breaking the script | ||
| fi | ||
| # Fallback for any other format - use branch name directly | ||
| echo "$specs_dir/$branch_name" |
There was a problem hiding this comment.
find_feature_dir_by_prefix passes raw branch_name (derived from CURRENT_BRANCH/SPECIFY_FEATURE) straight into feature_dir, which is then interpolated into the single-quoted assignments emitted by get_feature_paths and executed via eval $(get_feature_paths) in other scripts. An attacker who can create or select a branch name containing single quotes or command substitutions (e.g., feat/a'$(malicious_command) in a cloned repo or via a manually set SPECIFY_FEATURE) can break out of the single quotes in FEATURE_DIR='...' and inject arbitrary shell commands when these scripts run. To fix this, avoid using eval on the output of get_feature_paths, or ensure that branch-derived values are strictly sanitized/encoded so they cannot contain characters that break single-quoted shell assignments before they are echoed and eval'd.
Summary
001-feature-name)を廃止し、Conventional Commit形式(type/description)のみを許可するように変更feat,fix,refactor,docs,chore,style,test,perf,ci,buildspec.mdがある場合はテンプレート上書きをスキップChanges
.specify/scripts/bash/common.sh:check_feature_branchとfind_feature_dir_by_prefixをConventional Commit形式に対応.specify/scripts/bash/create-new-feature.sh:--numberオプションを--typeオプションに変更、フィーチャーブランチ検出ロジックを追加Test plan
type/description形式で作成されるspec.mdがある場合、上書きされない🤖 Generated with Claude Code