Skip to content

Commit a8e710e

Browse files
fsilvaortizclaude
andcommitted
fix: use PSBoundParameters to distinguish explicit -Number 0 from default
Addresses Copilot review — previously -Number 0 silently fell through to auto-detect. Now uses $PSBoundParameters.ContainsKey('Number') to reject explicitly passed values < 1, matching Bash behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1 parent 6cf7bd1 commit a8e710e

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

‎scripts/powershell/create-new-feature.ps1‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ if ($Timestamp) {
201201
$featureNum = Get-Date -Format 'yyyyMMdd-HHmmss'
202202
$branchName = "$featureNum-$branchSuffix"
203203
} else {
204-
# Validate -Number input when provided
205-
if ($Number -lt 0) {
204+
# Validate -Number input when explicitly provided
205+
if ($PSBoundParameters.ContainsKey('Number') -and $Number -lt 1) {
206206
Write-Error "-Number requires a positive integer, got $Number"
207207
exit 1
208208
}

‎tests/test_timestamp_branches.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,11 @@ def test_powershell_supports_allow_existing_branch_flag(self):
453453
# Ensure the flag is referenced in script logic, not just declared
454454
assert "AllowExistingBranch" in contents.replace("-AllowExistingBranch", "")
455455

456-
def test_powershell_rejects_negative_number(self):
457-
"""Static guard: PS script validates -Number is not negative."""
456+
def test_powershell_rejects_invalid_number(self):
457+
"""Static guard: PS script validates -Number using PSBoundParameters and rejects < 1."""
458458
contents = CREATE_FEATURE_PS.read_text(encoding="utf-8")
459-
assert "Number -lt 0" in contents or re.search(r"\$Number\s+-lt\s+0", contents)
459+
assert "PSBoundParameters.ContainsKey" in contents
460+
assert "Number -lt 1" in contents or re.search(r"\$Number\s+-lt\s+1", contents)
460461
assert "positive integer" in contents
461462

462463
def test_powershell_has_number_collision_validation(self):

0 commit comments

Comments
 (0)