-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix: check all git branches for feature numbering to prevent duplicates #1023
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 #1023
Conversation
Fixes github#975 The create-new-feature.ps1 script now checks all existing git branches (not just branches with the same short name) when determining the next feature number. This prevents duplicate feature numbers when multiple feature branches exist that haven't been merged to main. Changes: - Updated Get-NextBranchNumber to check ALL branches matching ^\d{3}- - Removed ShortName parameter from function (no longer needed) - Now checks remote, local branches, and specs/ directory for all features - Uses highest number found from any source + 1
Fixes github#975 The create-new-feature.ps1 script now checks ALL existing git branches (not just branches with the same short name) when determining the next feature number. This prevents duplicate feature numbers when multiple feature branches exist that haven't been merged to main. Changes: - Removed ShortName parameter from Get-NextBranchNumber function - Updated regex patterns to match ALL branches with ^\d{3}- pattern - Remote branches: changed from refs/heads/(\d+)-$ShortName$ to refs/heads/(\d{3})- - Local branches: changed from ^\*?\s*(\d+)-$ShortName$ to ^\*?\s*(\d{3})- - Specs directory: changed from ^(\d+)-$ShortName$ to ^(\d{3})- - Updated function call on line 211 to remove -ShortName parameter - Now correctly finds highest feature number across ALL features
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 fixes a bug where the Get-NextBranchNumber function was only checking branches with the same short name when determining the next feature number, which caused duplicate feature numbers when multiple feature branches existed that hadn't been merged to main.
Key Changes:
- Removed the
$ShortNameparameter fromGet-NextBranchNumberto check all feature branches instead of filtering by name - Updated all regex patterns to match any branch starting with a 3-digit number followed by a hyphen (
^\d{3}-) - Updated the function call to remove the
-ShortNameparameter
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| # Calculate how much we need to trim from suffix | ||
| # Account for: feature number (3) + hyphen (1) = 4 chars | ||
| $maxSuffixLength = $maxBranchLength - 4 | ||
| $maxSuffixLength = $maxBranchLength - 4; |
Copilot
AI
Oct 23, 2025
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.
Semicolons are unnecessary in PowerShell and inconsistent with the rest of the file's style. Remove the semicolon at the end of this line.
| $maxSuffixLength = $maxBranchLength - 4; | |
| $maxSuffixLength = $maxBranchLength - 4 |
| $originalBranchName = $branchName; | ||
| $branchName = "$featureNum-$truncatedSuffix"; |
Copilot
AI
Oct 23, 2025
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.
Semicolons are unnecessary in PowerShell and inconsistent with the rest of the file's style. Remove the semicolons at the end of these lines.
Fixes #975
Problem
The
Get-NextBranchNumberfunction was 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.Solution
Updated the function to check ALL existing git branches matching the pattern
^\d{3}-instead of only branches with the same short name.Changes
$ShortNameparameter fromGet-NextBranchNumberfunctionrefs/heads/(\d{3})-^\*?\s*(\d{3})-^(\d{3})--ShortNameparameter