Skip to content

fix: support feature branch numbers with 4+ digits#2040

Merged
mnriem merged 4 commits intogithub:mainfrom
t-sakoda:fix/support-variable-length-feature-numbers
Apr 2, 2026
Merged

fix: support feature branch numbers with 4+ digits#2040
mnriem merged 4 commits intogithub:mainfrom
t-sakoda:fix/support-variable-length-feature-numbers

Conversation

@t-sakoda
Copy link
Copy Markdown
Contributor

@t-sakoda t-sakoda commented Apr 1, 2026

Description

The sequential feature number regex in common.sh and common.ps1 was hardcoded to exactly 3 digits ({3}), causing branches like 1234-feature-name to 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 in check_feature_branch / Test-FeatureBranch to prevent malformed timestamps (e.g. 2026031-143022-feat) from being falsely accepted as sequential prefixes.

Closes #344

Testing

  • Tested locally with uv run specify --help
  • Ran existing tests with uv sync && uv run pytest
  • Tested with a sample project (if applicable)

All 27 test_timestamp_branches.py tests pass, including the existing test that rejects partial timestamps.

AI Disclosure

  • I did not use AI assistance for this contribution
  • I did use AI assistance (describe below)

Code changes generated and reviewed with Claude Code (Claude Opus 4.6).

…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>
Copilot AI review requested due to automatic review settings April 1, 2026 05:53
Copy link
Copy Markdown
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

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 scanning specs/ 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>
@t-sakoda t-sakoda marked this pull request as ready for review April 1, 2026 06:29
@t-sakoda t-sakoda requested a review from mnriem as a code owner April 1, 2026 06:29
Copilot AI review requested due to automatic review settings April 1, 2026 06:29
Copy link
Copy Markdown
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

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

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 case 20260319-143022 (8-digit date + 6-digit time with no final -<slug>). Adding a test that asserts check_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.

Copy link
Copy Markdown
Collaborator

@mnriem mnriem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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.

@t-sakoda t-sakoda requested a review from mnriem April 2, 2026 00:52
@mnriem mnriem merged commit 8e14ab1 into github:main Apr 2, 2026
11 of 12 checks passed
@mnriem
Copy link
Copy Markdown
Collaborator

mnriem commented Apr 2, 2026

Thank you!

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.

Customize Feature Number to include External Reference

3 participants