-
Notifications
You must be signed in to change notification settings - Fork 3.9k
fix: check all git branches for feature numbering to prevent duplicates #1109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix: check all git branches for feature numbering to prevent duplicates #1109
Conversation
Fixes github#1101 Removed short_name filter from branch detection to check ALL branches instead of only branches matching the current feature name pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR modifies the check_existing_branches() function to broaden the scope of branch detection. Instead of filtering branches by the specific short_name parameter, it now finds all branches following the numeric prefix pattern ([0-9]+-).
- Changed grep patterns to remove
short_namefiltering in remote and local branch detection - Affects how the script determines the next available branch number
Comments suppressed due to low confidence (2)
scripts/bash/create-new-feature.sh:99
- The spec_dirs check on line 99 still filters by
${short_name}, creating an inconsistency with the updated remote and local branch checks on lines 91 and 94. This means the function will now find the highest branch number across ALL branches (lines 91, 94), but only consider spec directories matching the specific short name (line 99). This could lead to branch number conflicts if different branch names exist. Either remove${short_name}from line 99 to match the new behavior, or revert lines 91 and 94 to include the${short_name}filter for consistency.
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)
scripts/bash/create-new-feature.sh:85
- The
short_nameparameter is now only used on line 99 for spec directory filtering but is no longer used for remote/local branch filtering on lines 91 and 94. If the intention is to find the highest branch number across all branches regardless of name, consider removing this parameter entirely and updating line 99 accordingly. Alternatively, if branch-specific numbering is still desired, the grep patterns on lines 91 and 94 should be reverted to include${short_name}filtering.
local short_name="$1"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
HI there, i think this won't completly fix the problem with the branch numbering when using coding agents because the speckit.specify command prompt template instructs the agent to call the script with the Number parameter which bypasses this solution. Template (Source) Template (fix)
Am i correct? |
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.
Updated template to instruct AI agents to check ALL feature branches instead of filtering by short-name, completing the fix across scripts and templates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
scripts/bash/create-new-feature.sh:85
- The parameter
short_nameis accepted by the function but is no longer used anywhere in the function body after the changes. This parameter should be removed from the function signature, and the function call at line 196 should be updated tocheck_existing_brancheswithout passing$BRANCH_SUFFIX.
local short_name="$1"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@maxmeyer3141 You're right! I've just added commits a005e81 and b0dc835 that update both the Bash script and the |
Removed unused parameter from check_existing_branches function to address Copilot AI code review feedback.
Fixes #1101
Problem
The
check_existing_branchesfunction inscripts/bash/create-new-feature.shwas checking only branches with the same short name when determining the next feature number, causing duplicate feature numbers when multiple feature branches exist that haven't been merged to main.This is the same bug that was fixed for PowerShell in #1023, but affecting the Bash script.
Solution
Updated the function to check ALL existing git branches matching the pattern
[0-9]+-instead of only branches with the same short name.Changes
check_existing_branchesfunctiongrep -E "refs/heads/[0-9]+-${short_name}$"togrep -E "refs/heads/[0-9]+-"grep -E "^[* ]*[0-9]+-${short_name}$"togrep -E "^[* ]*[0-9]+-"Example
Before (buggy behavior):
001-build-an-account,002-oauth2-google-auth--short-name multilingual-support001-multilingual-support❌ (WRONG - duplicate!)After (correct behavior):
001-build-an-account,002-oauth2-google-auth--short-name multilingual-support003-multilingual-support✅ (CORRECT - next sequential number)Related
This completes the fix started in #1023, resolving the duplicate numbering issue for both PowerShell and Bash users.