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

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

create-new-feature-branch.ps1 emitted a HAS_GIT key in its JSON output and a 'HAS_GIT:' line in text output that the bash twin never emits. The bash output contract is {BRANCH_NAME, FEATURE_NUM} (+ DRY_RUN) only, so a tool parsing the machine-readable output got a different shape on Windows/PowerShell vs macOS/Linux -- a cross-platform contract divergence.

$hasGit is still computed and used internally for branch-creation logic; only its two output emissions are removed, restoring parity. Added regression tests asserting neither the PS nor the bash output contains HAS_GIT (JSON and text). Noted as a follow-up in #3129.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* docs: note DRY_RUN in the HAS_GIT-omission comment (parity)

Address Copilot review: the comment described the output contract as {BRANCH_NAME, FEATURE_NUM} without mentioning that DRY_RUN is still conditionally added in JSON mode on dry runs. Clarify so the contract description is complete for future maintainers. Comment-only.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ali jawwad
2026-06-30 00:36:17 +05:00
committed by GitHub
parent 7621e1ceba
commit 7b687d8bbd
2 changed files with 39 additions and 2 deletions

View File

@@ -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)."""