Skip to content

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

Open
jawwad-ali wants to merge 1 commit into
github:mainfrom
jawwad-ali:fix/ps-git-ext-has-git-output-parity
Open

fix(scripts): drop HAS_GIT from PowerShell git-extension output (parity with bash)#3195
jawwad-ali wants to merge 1 commit into
github:mainfrom
jawwad-ali:fix/ps-git-ext-has-git-output-parity

Conversation

@jawwad-ali

Copy link
Copy Markdown
Contributor

Description

The git extension's create-new-feature-branch.ps1 emits a HAS_GIT field in its JSON output and a HAS_GIT: line in its text output that the bash twin never emits.

The bash twin's output contract is:

  • JSON: {BRANCH_NAME, FEATURE_NUM} (+ DRY_RUN on dry runs)
  • text: BRANCH_NAME: / FEATURE_NUM: lines

So any tool consuming the machine-readable output gets a different shape on Windows/PowerShell than on macOS/Linux — a cross-platform output-contract divergence. (I flagged this as a follow-up in #3129.)

Fix

Remove the two HAS_GIT output emissions from the PowerShell script (JSON object + text line). $hasGit is still computed and used internally for branch-creation logic — only its leakage into the output contract is removed, restoring parity with bash. One-file change.

Testing

  • uvx ruff check clean; tests/test_ps1_encoding.py green (the edited .ps1 stays ASCII / PowerShell 5.1-safe).
  • New regression tests in tests/extensions/git/test_git_extension.py:
    • TestCreateFeatureBash::test_output_omits_has_git_for_parity — pins the canonical bash contract (JSON + text omit HAS_GIT).
    • TestCreateFeaturePowerShell::test_output_omits_has_git_to_match_bashfails before this change (PS emitted HAS_GIT), passes after.
  • Verified end-to-end with Windows PowerShell 5.1 and bash: both now emit identical JSON {"BRANCH_NAME":"001-parity","FEATURE_NUM":"001","DRY_RUN":true}, and PS text mode no longer prints a HAS_GIT: line.

AI Disclosure

  • I did use AI assistance (describe below)

Found and fixed with Claude Code (Claude Opus 4.8) under my direction. AI located the output-contract divergence across the bash/PowerShell twins and drafted the one-line removal plus regression tests; I reproduced the differing JSON shapes under Windows PowerShell 5.1 and bash, confirmed $hasGit's internal use is unaffected, and reviewed the diff before submitting.

…ty 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 github#3129.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jawwad-ali jawwad-ali requested a review from mnriem as a code owner June 27, 2026 12:55
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