Skip to content

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

Merged
mnriem merged 2 commits into
github:mainfrom
jawwad-ali:fix/ps-git-ext-has-git-output-parity
Jun 29, 2026
Merged

fix(scripts): drop HAS_GIT from PowerShell git-extension output (parity with bash)#3195
mnriem merged 2 commits 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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Aligns the Windows/PowerShell git-extension script output contract with its bash twin by removing the leaked HAS_GIT field/line from machine- and human-readable outputs, and adds regression coverage to prevent cross-platform output-shape drift.

Changes:

  • Remove HAS_GIT from create-new-feature-branch.ps1 JSON/text output while keeping $hasGit for internal branch-creation logic.
  • Add bash + PowerShell regression tests pinning the canonical output contract (no HAS_GIT in JSON or text output).
Show a summary per file
File Description
extensions/git/scripts/powershell/create-new-feature-branch.ps1 Drops HAS_GIT from emitted output to match bash output shape.
tests/extensions/git/test_git_extension.py Adds regression tests asserting HAS_GIT is absent in both bash and PowerShell outputs.

Review details

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment thread extensions/git/scripts/powershell/create-new-feature-branch.ps1 Outdated

@mnriem mnriem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address Copilot feedback

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>
@jawwad-ali

Copy link
Copy Markdown
Contributor Author

@mnriem addressed Copilot's feedback in 750578b — the HAS_GIT-omission comment now also notes that DRY_RUN is conditionally emitted on dry runs, so the contract description is complete. Comment-only; thread resolved.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Low

@mnriem mnriem self-requested a review June 29, 2026 19:35
@mnriem mnriem merged commit 7b687d8 into github:main Jun 29, 2026
12 checks passed
@mnriem

mnriem commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

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.

3 participants