Skip to content

fix: Use global branch numbering instead of per-short-name numbering (Issue #34)#45

Merged
kanfil merged 1 commit intomainfrom
fix/global-branch-numbering
Feb 26, 2026
Merged

fix: Use global branch numbering instead of per-short-name numbering (Issue #34)#45
kanfil merged 1 commit intomainfrom
fix/global-branch-numbering

Conversation

@kanfil
Copy link
Copy Markdown
Member

@kanfil kanfil commented Feb 26, 2026

Summary

Fixes the bug where spec.specify creates multiple branches with the same 001 prefix when creating different features.

Problem

The AI instructions in templates/commands/specify.md were telling the agent to:

  1. Only search for branches matching the exact short-name pattern (e.g., *-user-auth)
  2. If no matching branches found, start with number 1

This caused the following scenario:

  • Create 001-user-auth
  • Create 001-payment-gateway (DUPLICATE - should be 002)
  • Create 001-analytics-dashboard (DUPLICATE - should be 003)

Solution

Remove the AI pre-calculation of branch numbers and let the bash script handle numbering automatically. The script already has the correct global numbering logic in:

  • get_highest_from_branches() - checks ALL branches regardless of short-name
  • check_existing_branches() - combines branches and specs to find the next global number

Before (broken)

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]+-<short-name>$'`
   ...
   - If no existing branches/directories found with this short-name, start with number 1

After (fixed)

Run the script `{SCRIPT}` with the short-name, mode, and options. The script will automatically 
determine the next available global number by checking ALL existing branches and specs.

- Do NOT pass `--number` - let the script auto-detect the next global number

Related Issues

Testing

After this fix:

  • Create 001-user-auth
  • Create 002-payment-gateway (correct!)
  • Create 003-analytics-dashboard (correct!)

Remove the AI pre-calculation of branch numbers which was incorrectly
matching only branches with the exact short-name pattern. This caused
duplicate 001 prefixes when creating different features.

Now the script auto-detects the next global number by checking ALL
existing branches and specs directories, ensuring unique sequential
numbering (001, 002, 003...) regardless of feature short-names.

The bash script already had the correct global numbering logic in
get_highest_from_branches() and check_existing_branches() functions.

Fixes: #34
Related upstream issues: github#1066, github#1332, github#1454
Aligned with upstream PR: github#1466
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 26, 2026

⚠️ No evaluation results found

@kanfil kanfil merged commit 498070b into main Feb 26, 2026
9 checks passed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 2, 2026

📊 Eval Results

Overall: 7/25 tests passed (28%)

Metric Value
✅ Passed 7
❌ Failed 18
📈 Pass Rate 28%
🪙 Total Tokens 121,022
💾 Cached Tokens 0

❌ Failed Tests

  • Unknown (score: 0.86)
  • Unknown (score: 0.83)
  • Unknown (score: 0.80)
  • Unknown (score: 0.80)
  • Unknown (score: 0.78)
  • Unknown (score: 0.79)
  • Unknown (score: 0.86)
  • Unknown (score: 0.89)
  • Unknown (score: 0.71)
  • Unknown (score: 0.83)
  • Unknown (score: 0.83)
  • Unknown (score: 0.89)
  • Unknown (score: 0.83)
  • Unknown (score: 0.68)
  • Unknown (score: 0.68)
  • Unknown (score: 0.95)
  • Unknown (score: 0.87)
  • Unknown (score: 0.79)

⚠️ Quality thresholds not met (target: 85%). Please review failures.

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.

[Bug]: spec.specify creates multiple branches with 001 prefix

1 participant