fix(git-ext): honor explicit -Number 0 in PowerShell branch creation (parity with bash)#3412
Open
Noor-ul-ain001 wants to merge 1 commit into
Open
Conversation
`-Number` defaults to 0, so the previous `-eq 0` / `-ne 0` checks could
not distinguish an unset flag from an explicit `-Number 0`: a user
requesting branch `000-...` was silently routed into auto-detection.
Switch both checks to `$PSBoundParameters.ContainsKey('Number')`, which
tests whether the flag was actually supplied — mirroring the bash twin's
empty-string sentinel (`[ -z "$BRANCH_NUMBER" ]` / `[ -n ... ]`).
Add a parity regression test to both TestCreateFeatureBash and
TestCreateFeaturePowerShell asserting `--number 0` / `-Number 0` yields
`000-zero`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The git extension's PowerShell branch-creation script silently ignored an explicit
-Number 0. Because-Numberis declared with a default of0, the guardsif ($Timestamp -and $Number -ne 0)andif ($Number -eq 0)could not tell an unset flag apart from a user passing-Number 0. A user asking for branch000-...was routed into auto-detection and got the next sequential number instead.This mirrors the same fix already landed for the core script in #3196 (
scripts/powershell/create-new-feature.ps1) — the git-extension twin (extensions/git/scripts/powershell/create-new-feature-branch.ps1) still carried the bug.Changes
-eq 0/-ne 0checks with$PSBoundParameters.ContainsKey('Number'), which tests whether the flag was actually supplied — mirroring the bash twin's empty-string sentinel (BRANCH_NUMBER="",[ -z "$BRANCH_NUMBER" ]/[ -n "$BRANCH_NUMBER" ]).TestCreateFeatureBashandTestCreateFeaturePowerShellasserting--number 0/-Number 0yields000-zero/FEATURE_NUM=000.Testing
Verified both twins manually (pwsh Core / real Git-for-Windows bash are gated by
HAS_PWSH/requires_bashin CI):-Number 0000-zero000-zero-Number 5005-five001spec)001-auto001-auto(parity)🤖 Generated with Claude Code