From 666ac653cd2572d14655abfce7521c6af97414e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cashwinhegde19=E2=80=9D?= <“ashwinhegde19@gmail.com”> Date: Tue, 4 Nov 2025 01:01:43 +0530 Subject: [PATCH 1/4] fix: check all git branches for feature numbering to prevent duplicates Fixes #1101 Removed short_name filter from branch detection to check ALL branches instead of only branches matching the current feature name pattern. --- scripts/bash/create-new-feature.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/bash/create-new-feature.sh b/scripts/bash/create-new-feature.sh index 86d9ecf83..b6b5db503 100644 --- a/scripts/bash/create-new-feature.sh +++ b/scripts/bash/create-new-feature.sh @@ -88,10 +88,10 @@ check_existing_branches() { git fetch --all --prune 2>/dev/null || true # Find all branches matching the pattern using git ls-remote (more reliable) - local remote_branches=$(git ls-remote --heads origin 2>/dev/null | grep -E "refs/heads/[0-9]+-${short_name}$" | sed 's/.*\/\([0-9]*\)-.*/\1/' | sort -n) + local remote_branches=$(git ls-remote --heads origin 2>/dev/null | grep -E "refs/heads/[0-9]+-" | sed 's/.*\/\([0-9]*\)-.*/\1/' | sort -n) # Also check local branches - local local_branches=$(git branch 2>/dev/null | grep -E "^[* ]*[0-9]+-${short_name}$" | sed 's/^[* ]*//' | sed 's/-.*//' | sort -n) + local local_branches=$(git branch 2>/dev/null | grep -E "^[* ]*[0-9]+-" | sed 's/^[* ]*//' | sed 's/-.*//' | sort -n) # Check specs directory as well local spec_dirs="" From a005e81a435e260b8d28b5d3f362aa0807b283a8 Mon Sep 17 00:00:00 2001 From: ashwinhegde19 Date: Tue, 4 Nov 2025 02:13:36 +0530 Subject: [PATCH 2/4] fix: update spec_dirs check to match all feature directories Removed short_name filter from spec directory checking to ensure consistent branch numbering across all three sources (remote branches, local branches, and spec directories). Addresses Copilot AI feedback from PR review. --- scripts/bash/create-new-feature.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/bash/create-new-feature.sh b/scripts/bash/create-new-feature.sh index b6b5db503..db96a375c 100644 --- a/scripts/bash/create-new-feature.sh +++ b/scripts/bash/create-new-feature.sh @@ -96,7 +96,7 @@ check_existing_branches() { # Check specs directory as well local spec_dirs="" if [ -d "$SPECS_DIR" ]; then - spec_dirs=$(find "$SPECS_DIR" -maxdepth 1 -type d -name "[0-9]*-${short_name}" 2>/dev/null | xargs -n1 basename 2>/dev/null | sed 's/-.*//' | sort -n) + spec_dirs=$(find "$SPECS_DIR" -maxdepth 1 -type d -name "[0-9]*-*" 2>/dev/null | xargs -n1 basename 2>/dev/null | sed 's/-.*//' | sort -n) fi # Combine all sources and get the highest number From b0dc835e26e16a5c0c8c0786eb300e21df0fbc83 Mon Sep 17 00:00:00 2001 From: ashwinhegde19 Date: Tue, 4 Nov 2025 02:22:01 +0530 Subject: [PATCH 3/4] fix: ensure specify.md template checks all branches Updated template to instruct AI agents to check ALL feature branches instead of filtering by short-name, completing the fix across scripts and templates. --- templates/commands/specify.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/commands/specify.md b/templates/commands/specify.md index 69258a8bf..077106b45 100644 --- a/templates/commands/specify.md +++ b/templates/commands/specify.md @@ -38,10 +38,10 @@ Given that feature description, do this: git fetch --all --prune ``` - b. Find the highest feature number across all sources for the short-name: - - Remote branches: `git ls-remote --heads origin | grep -E 'refs/heads/[0-9]+-$'` - - Local branches: `git branch | grep -E '^[* ]*[0-9]+-$'` - - Specs directories: Check for directories matching `specs/[0-9]+-` + b. Find the highest feature number across all sources: + - Remote branches: `git ls-remote --heads origin | grep -E 'refs/heads/[0-9]+-'` + - Local branches: `git branch | grep -E '^[* ]*[0-9]+-'` + - Specs directories: Check for directories matching `specs/[0-9]+-*` c. Determine the next available number: - Extract all numbers from all three sources @@ -55,8 +55,8 @@ Given that feature description, do this: **IMPORTANT**: - Check all three sources (remote branches, local branches, specs directories) to find the highest number - - Only match branches/directories with the exact short-name pattern - - If no existing branches/directories found with this short-name, start with number 1 + - Find the highest number across ALL branches/directories with the numeric prefix pattern `[0-9]+-` + - If no existing branches/directories found, start with number 1 - You must only ever run this script once per feature - The JSON is provided in the terminal as output - always refer to it to get the actual content you're looking for - The JSON output will contain BRANCH_NAME and SPEC_FILE paths From 05885f81e74668e1f39aba9f1f960741be781ef2 Mon Sep 17 00:00:00 2001 From: ashwinhegde19 Date: Tue, 4 Nov 2025 02:33:19 +0530 Subject: [PATCH 4/4] refactor: remove unused short_name parameter Removed unused parameter from check_existing_branches function to address Copilot AI code review feedback. --- scripts/bash/create-new-feature.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/bash/create-new-feature.sh b/scripts/bash/create-new-feature.sh index db96a375c..708706ec8 100644 --- a/scripts/bash/create-new-feature.sh +++ b/scripts/bash/create-new-feature.sh @@ -82,7 +82,6 @@ find_repo_root() { # Function to check existing branches (local and remote) and return next available number check_existing_branches() { - local short_name="$1" # Fetch all remotes to get latest branch info (suppress errors if no remotes) git fetch --all --prune 2>/dev/null || true @@ -193,7 +192,7 @@ fi if [ -z "$BRANCH_NUMBER" ]; then if [ "$HAS_GIT" = true ]; then # Check existing branches on remotes - BRANCH_NUMBER=$(check_existing_branches "$BRANCH_SUFFIX") + BRANCH_NUMBER=$(check_existing_branches) else # Fall back to local directory check HIGHEST=0