Skip to content

💫 Toolkit to help you get started with SDD or any other process!

fix(scripts): drop HAS_GIT from PowerShell git-extension output (parity with bash) (#3195)

Ali jawwad7b687d8bbda5
diff --git a/extensions/git/scripts/powershell/create-new-feature-branch.ps1 b/extensions/git/scripts/powershell/create-new-feature-branch.ps1
index 6a4417f8b..597bdf40d 100644
--- a/extensions/git/scripts/powershell/create-new-feature-branch.ps1
+++ b/extensions/git/scripts/powershell/create-new-feature-branch.ps1
@@ -400,8 +400,10 @@ if ($Json) {
$obj = [PSCustomObject]@{
BRANCH_NAME = $branchName
FEATURE_NUM = $featureNum
- HAS_GIT = $hasGit
}
+ # $hasGit is computed for branch-creation logic only; it is intentionally not
+ # emitted so this output contract matches the bash twin: BRANCH_NAME and
+ # FEATURE_NUM, plus DRY_RUN (added just below) on dry runs.
if ($DryRun) {
$obj | Add-Member -NotePropertyName 'DRY_RUN' -NotePropertyValue $true
}
@@ -409,7 +411,6 @@ if ($Json) {
} else {
Write-Output "BRANCH_NAME: $branchName"
Write-Output "FEATURE_NUM: $featureNum"
- Write-Output "HAS_GIT: $hasGit"
if (-not $DryRun) {
Write-Output "SPECIFY_FEATURE environment variable set to: $branchName"
}
diff --git a/tests/extensions/git/test_git_extension.py b/tests/extensions/git/test_git_extension.py
index 2017dae62..1a291f030 100644
--- a/tests/extensions/git/test_git_extension.py
+++ b/tests/extensions/git/test_git_extension.py
@@ -298,6 +298,24 @@ class TestCreateFeatureBash:
assert data["BRANCH_NAME"] == "001-user-auth"
assert data["FEATURE_NUM"] == "001"
+ def test_output_omits_has_git_for_parity(self, tmp_path: Path):
+ """The bash output contract is {BRANCH_NAME, FEATURE_NUM} (+ DRY_RUN) in JSON
+ and a BRANCH_NAME:/FEATURE_NUM: text block -- no HAS_GIT key/line. This pins
+ the canonical contract the PowerShell twin must mirror."""
+ project = _setup_project(tmp_path)
+ rj = _run_bash(
+ "create-new-feature-branch.sh", project,
+ "--json", "--dry-run", "--short-name", "parity", "Parity feature",
+ )
+ assert rj.returncode == 0, rj.stderr
+ assert "HAS_GIT" not in json.loads(rj.stdout)
+ rt = _run_bash(
+ "create-new-feature-branch.sh", project,
+ "--dry-run", "--short-name", "parity", "Parity feature",
+ )
+ assert rt.returncode == 0, rt.stderr
+ assert "HAS_GIT" not in rt.stdout
+
def test_branch_name_short_word_case_sensitivity(self, tmp_path: Path):
"""A short word is dropped from the derived branch name unless it appears
as an acronym in UPPERCASE in the description (case-sensitive, must match the
@@ -444,6 +462,24 @@ class TestCreateFeaturePowerShell:
data = json.loads(result.stdout)
assert data["BRANCH_NAME"] == "001-user-auth"
+ def test_output_omits_has_git_to_match_bash(self, tmp_path: Path):
+ """PowerShell must mirror the bash twin's output contract: neither JSON nor
+ text output may include HAS_GIT (it is computed internally for branch-creation
+ logic only). Fails before the fix (PS emitted HAS_GIT), passes after."""
+ project = _setup_project(tmp_path)
+ rj = _run_pwsh(
+ "create-new-feature-branch.ps1", project,
+ "-Json", "-DryRun", "-ShortName", "parity", "Parity feature",
+ )
+ assert rj.returncode == 0, rj.stderr
+ assert "HAS_GIT" not in json.loads(rj.stdout)
+ rt = _run_pwsh(
+ "create-new-feature-branch.ps1", project,
+ "-DryRun", "-ShortName", "parity", "Parity feature",
+ )
+ assert rt.returncode == 0, rt.stderr
+ assert "HAS_GIT" not in rt.stdout
+
def test_branch_name_short_word_case_sensitivity(self, tmp_path: Path):
"""PowerShell must match the bash twin: a short word is dropped unless it
appears as an acronym in UPPERCASE (case-sensitive -cmatch, not -match)."""