fix(scripts): drop HAS_GIT from PowerShell git-extension output (parity with bash)#3195
Merged
mnriem merged 2 commits intoJun 29, 2026
Merged
Conversation
…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>
Contributor
There was a problem hiding this comment.
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_GITfromcreate-new-feature-branch.ps1JSON/text output while keeping$hasGitfor internal branch-creation logic. - Add bash + PowerShell regression tests pinning the canonical output contract (no
HAS_GITin 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
mnriem
requested changes
Jun 29, 2026
mnriem
left a comment
Collaborator
There was a problem hiding this comment.
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>
Contributor
Author
mnriem
approved these changes
Jun 29, 2026
Collaborator
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The git extension's
create-new-feature-branch.ps1emits aHAS_GITfield in its JSON output and aHAS_GIT:line in its text output that the bash twin never emits.The bash twin's output contract is:
{BRANCH_NAME, FEATURE_NUM}(+DRY_RUNon dry runs)BRANCH_NAME:/FEATURE_NUM:linesSo 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_GIToutput emissions from the PowerShell script (JSON object + text line).$hasGitis 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 checkclean;tests/test_ps1_encoding.pygreen (the edited.ps1stays ASCII / PowerShell 5.1-safe).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_bash— fails before this change (PS emitted HAS_GIT), passes after.{"BRANCH_NAME":"001-parity","FEATURE_NUM":"001","DRY_RUN":true}, and PS text mode no longer prints aHAS_GIT:line.AI Disclosure
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.