Skip to content

Conversation

@Ashwinhegde19
Copy link

Fixes #975

Problem

The Get-NextBranchNumber function 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

  • Removed $ShortName parameter from Get-NextBranchNumber function
  • Updated regex patterns to match ALL feature branches:
    • Remote: refs/heads/(\d{3})-
    • Local: ^\*?\s*(\d{3})-
    • Specs: ^(\d{3})-
  • Updated function call to remove -ShortName parameter
  • Now correctly finds highest feature number across ALL features

Ashwinhegde19 and others added 3 commits October 23, 2025 23:41
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
@Copilot Copilot AI review requested due to automatic review settings October 23, 2025 18:22
Copy link
Contributor

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

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 $ShortName parameter from Get-NextBranchNumber to 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 -ShortName parameter

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;
Copy link

Copilot AI Oct 23, 2025

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.

Suggested change
$maxSuffixLength = $maxBranchLength - 4;
$maxSuffixLength = $maxBranchLength - 4

Copilot uses AI. Check for mistakes.
Comment on lines 242 to 243
$originalBranchName = $branchName;
$branchName = "$featureNum-$truncatedSuffix";
Copy link

Copilot AI Oct 23, 2025

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.

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.

Potential bug with the create-new-feature.ps1 script that ignores existing feature branches when determining next feature number

1 participant