fix: support feature branch numbers with 4+ digits#2040
Conversation
…ommon.ps1
The sequential feature number pattern was hardcoded to exactly 3 digits
(`{3}`), causing branches like `1234-feature-name` to be rejected.
Changed to `{3,}` (3 or more digits) to support growing projects.
Also added a guard to exclude malformed timestamp patterns from being
accepted as sequential prefixes.
Closes github#344
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates feature-branch parsing in Spec Kit’s Bash and PowerShell helper scripts to support sequential prefixes beyond 999 (3+ digits) while preventing malformed timestamp-like prefixes from being treated as sequential.
Changes:
- Allow sequential feature prefixes with 3+ digits (
{3,}) when scanningspecs/and resolving feature directories. - Update feature-branch validation to accept 4+ digit sequential prefixes.
- Add a guard intended to reject malformed timestamp-like branches (e.g.,
2026031-143022-feat) from being accepted as sequential.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| scripts/powershell/common.ps1 | Expands sequential prefix matching and adds a timestamp-shape guard in Test-FeatureBranch. |
| scripts/bash/common.sh | Expands sequential prefix matching, updates prefix-based directory resolution, and adds the same timestamp-shape guard in check_feature_branch. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Change [int] to [long] in PowerShell Get-CurrentBranch to avoid
overflow for large feature numbers (>2,147,483,647)
- Narrow malformed-timestamp exclusion from ^[0-9]+-[0-9]{6}- to
^[0-9]{7}-[0-9]{6}- so valid sequential branches like
004-123456-fix-bug are not rejected
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Cover check_feature_branch and find_feature_dir_by_prefix with 4-digit sequential prefixes, as requested in PR review github#2040. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
tests/test_timestamp_branches.py:197
- There’s test coverage for rejecting a 7-digit partial date (
2026031-143022-feat), but no regression test for the newly-possible case20260319-143022(8-digit date + 6-digit time with no final-<slug>). Adding a test that assertscheck_feature_branch "20260319-143022" "true"fails would lock in the intended malformed-timestamp guard while still allowing 4+ digit sequential branches.
def test_accepts_four_digit_sequential_branch(self):
"""check_feature_branch accepts 4+ digit sequential branch."""
result = source_and_call('check_feature_branch "1234-feat" "true"')
assert result.returncode == 0
def test_rejects_partial_timestamp(self):
"""Test 9: check_feature_branch rejects 7-digit date."""
result = source_and_call('check_feature_branch "2026031-143022-feat" "true"')
assert result.returncode != 0
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mnriem
left a comment
There was a problem hiding this comment.
Please address Copilot feedback
Branches like "20260319-143022" (no "-<name>" suffix) were incorrectly accepted as sequential prefixes. Add explicit rejection for 7-or-8 digit date + 6-digit time patterns with no trailing slug, in both common.sh and common.ps1. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thank you! |
Description
The sequential feature number regex in
common.shandcommon.ps1was hardcoded to exactly 3 digits ({3}), causing branches like1234-feature-nameto be rejected once a project exceeds 999 features.This PR changes the pattern to
{3,}(3 or more digits) so that 4+ digit prefixes are recognized correctly. A guard is also added incheck_feature_branch/Test-FeatureBranchto prevent malformed timestamps (e.g.2026031-143022-feat) from being falsely accepted as sequential prefixes.Closes #344
Testing
uv run specify --helpuv sync && uv run pytestAll 27
test_timestamp_branches.pytests pass, including the existing test that rejects partial timestamps.AI Disclosure
Code changes generated and reviewed with Claude Code (Claude Opus 4.6).