fix(scripts): drop HAS_GIT from PowerShell git-extension output (parity with bash)#3195
Open
jawwad-ali wants to merge 1 commit into
Open
fix(scripts): drop HAS_GIT from PowerShell git-extension output (parity with bash)#3195jawwad-ali wants to merge 1 commit into
jawwad-ali wants to merge 1 commit into
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>
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.