Skip to content

fix(extensions/git): reject negative -Number in create-new-feature-branch.ps1#3538

Open
Noor-ul-ain001 wants to merge 1 commit into
github:mainfrom
Noor-ul-ain001:fix/ps-negative-number-branch
Open

fix(extensions/git): reject negative -Number in create-new-feature-branch.ps1#3538
Noor-ul-ain001 wants to merge 1 commit into
github:mainfrom
Noor-ul-ain001:fix/ps-negative-number-branch

Conversation

@Noor-ul-ain001

Copy link
Copy Markdown
Contributor

Summary

The create-new-feature-branch script has three twins (bash, PowerShell, Python). The bash and Python twins validate --number against ^[0-9]+$ and reject a negative value with:

Error: --number must be a non-negative integer

The PowerShell twin declares the parameter as [long]$Number, so PowerShell binds -5 as the integer -5 instead of rejecting it. That value then formats via '{0:000}' to -005 and produces a branch name starting with a dash — e.g. -005-my-feature — which git refuses (refs cannot begin with -). The user gets a confusing late git failure instead of the twins' clear, early error.

Fix

Tests

Added matching negative-number parity tests to both the bash and PowerShell create-feature suites, mirroring the existing test_explicit_number_zero_is_honored pair.

Verified manually on Windows PowerShell 5.1:

Same PowerShell-parity bug class as #3412 (-Number 0).

🤖 Generated with Claude Code

…anch.ps1

The bash and Python twins validate --number against ^[0-9]+$ and reject a
negative value with 'Error: --number must be a non-negative integer'. The
PowerShell twin declares the parameter as [long]$Number, so PowerShell binds
'-5' as -5 instead of rejecting it. That value then formats via '{0:000}' to
'-005' and yields a branch name starting with a dash, which git refuses (refs
cannot begin with '-') — a confusing late failure instead of the twins' clear
early error.

Guard for $Number -lt 0 up front (before the description check, matching the
bash twin's parse-time validation order) and emit the identical error. An
explicit -Number 0 is still honored, preserving the github#3412 fix.

Add matching negative-number parity tests to the bash and PowerShell
create-feature suites, mirroring the existing test_explicit_number_zero_is_honored
pair. Same PowerShell-parity bug class as github#3412.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Noor-ul-ain001 Noor-ul-ain001 requested a review from mnriem as a code owner July 15, 2026 09:05
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.

1 participant