Skip to content

refactor: ブランチ命名規則をConventional Commit形式に変更#60

Merged
sh1ma merged 1 commit intomainfrom
chore/conventional-branch-naming
Jan 9, 2026
Merged

refactor: ブランチ命名規則をConventional Commit形式に変更#60
sh1ma merged 1 commit intomainfrom
chore/conventional-branch-naming

Conversation

@sh1ma
Copy link
Owner

@sh1ma sh1ma commented Jan 9, 2026

Summary

  • 数値プレフィックス形式(001-feature-name)を廃止し、Conventional Commit形式(type/description)のみを許可するように変更
  • 有効なtype: feat, fix, refactor, docs, chore, style, test, perf, ci, build
  • 既存のフィーチャーブランチにいる場合は新規ブランチ作成をスキップ(worktree対応)
  • 既存のspec.mdがある場合はテンプレート上書きをスキップ

Changes

  • .specify/scripts/bash/common.sh: check_feature_branchfind_feature_dir_by_prefixをConventional Commit形式に対応
  • .specify/scripts/bash/create-new-feature.sh: --numberオプションを--typeオプションに変更、フィーチャーブランチ検出ロジックを追加

Test plan

  • 新しいフィーチャーブランチ作成時にtype/description形式で作成される
  • 既存のフィーチャーブランチ(worktree)にいる場合、新規ブランチが作成されない
  • 既存のspec.mdがある場合、上書きされない

🤖 Generated with Claude Code

- 数値プレフィックス形式(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>
Copilot AI review requested due to automatic review settings January 9, 2026 14:58
@claude
Copy link

claude bot commented Jan 9, 2026


Code review

No issues found. Checked for bugs and CLAUDE.md compliance.


@sh1ma sh1ma merged commit 5c8217f into main Jan 9, 2026
5 of 6 checks passed
@sh1ma sh1ma deleted the chore/conventional-branch-naming branch January 9, 2026 15:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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形式に対応するよう更新。ブランチ名バリデーションとディレクトリ名変換ロジックを修正

Comment on lines +97 to +104
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"
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants