From 000e7467ba871f01d7300d62ecbf49a4e42030c6 Mon Sep 17 00:00:00 2001 From: jawwad-ali Date: Wed, 22 Jul 2026 10:37:10 +0500 Subject: [PATCH 1/2] fix(scripts): git-ext PowerShell emits the '# To persist' SPECIFY_FEATURE hint (parity) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Git extension's create-new-feature-branch.ps1 printed a non-JSON hint 'SPECIFY_FEATURE environment variable set to: ', diverging from every twin: the bash (create-new-feature-branch.sh) and python (create_new_feature_branch.py) siblings of the same extension, and the core create-new-feature.ps1, all emit '# To persist in your shell: $env:SPECIFY_FEATURE = '''. The old wording is also misleading — $env:SPECIFY_FEATURE is set only in this child process and never reaches the agent's shell, so the actionable output is the persist hint. Mirror the core PS twin's $featureAssignment construction and message. Test (pwsh CI): the non-JSON output uses the '# To persist in your shell:' form (fails before: old wording). Verified end-to-end via powershell.exe. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../powershell/create-new-feature-branch.ps1 | 8 +++++++- tests/extensions/git/test_git_extension.py | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/extensions/git/scripts/powershell/create-new-feature-branch.ps1 b/extensions/git/scripts/powershell/create-new-feature-branch.ps1 index 1536f9a2ba..2d6f2bcfec 100644 --- a/extensions/git/scripts/powershell/create-new-feature-branch.ps1 +++ b/extensions/git/scripts/powershell/create-new-feature-branch.ps1 @@ -565,6 +565,12 @@ if (-not $DryRun) { $env:SPECIFY_FEATURE = $branchName } +# Build the PowerShell-idiomatic persist hint, mirroring the core +# create-new-feature.ps1 twin (and the bash/python twins of this script), which +# all emit "# To persist in your shell: ...". +$quotedBranchName = "'" + $branchName.Replace("'", "''") + "'" +$featureAssignment = '$env:SPECIFY_FEATURE = ' + $quotedBranchName + if ($Json) { $obj = [PSCustomObject]@{ BRANCH_NAME = $branchName @@ -581,6 +587,6 @@ if ($Json) { Write-Output "BRANCH_NAME: $branchName" Write-Output "FEATURE_NUM: $featureNum" if (-not $DryRun) { - Write-Output "SPECIFY_FEATURE environment variable set to: $branchName" + Write-Output "# To persist in your shell: $featureAssignment" } } diff --git a/tests/extensions/git/test_git_extension.py b/tests/extensions/git/test_git_extension.py index 79acfcb79e..dea46d3b4d 100644 --- a/tests/extensions/git/test_git_extension.py +++ b/tests/extensions/git/test_git_extension.py @@ -698,6 +698,22 @@ def test_output_omits_has_git_to_match_bash(self, tmp_path: Path): assert rt.returncode == 0, rt.stderr assert "HAS_GIT" not in rt.stdout + def test_persist_hint_matches_twins(self, tmp_path: Path): + """The non-JSON SPECIFY_FEATURE hint must use the '# To persist in your + shell: $env:SPECIFY_FEATURE = ''' form — matching the core + create-new-feature.ps1 twin and the bash/python twins of this script — + not the old 'environment variable set to:' wording (the env var is only + set in this child process, so the actionable output is the persist hint).""" + project = _setup_project(tmp_path) + result = _run_pwsh( + "create-new-feature-branch.ps1", project, + "-ShortName", "persist", "Persist hint feature", + ) + assert result.returncode == 0, result.stderr + assert "# To persist in your shell:" in result.stdout + assert "$env:SPECIFY_FEATURE = '001-persist'" in result.stdout + assert "environment variable set to:" not in result.stdout + def test_help_documents_branch_prefix(self, tmp_path: Path): """-Help documents both template config knobs.""" project = _setup_project(tmp_path) From 9d2fbd442481f3690e2ef532b8bcac7193840c74 Mon Sep 17 00:00:00 2001 From: jawwad-ali Date: Wed, 22 Jul 2026 18:49:32 +0500 Subject: [PATCH 2/2] docs(test): fix doubled apostrophe in persist-hint test docstring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address review: the docstring rendered the documented output form as ''' (two trailing apostrophes) instead of ''. Docstring-only; the assertions were already correct. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.8 (1M context) --- tests/extensions/git/test_git_extension.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/extensions/git/test_git_extension.py b/tests/extensions/git/test_git_extension.py index dea46d3b4d..1354af3947 100644 --- a/tests/extensions/git/test_git_extension.py +++ b/tests/extensions/git/test_git_extension.py @@ -700,7 +700,7 @@ def test_output_omits_has_git_to_match_bash(self, tmp_path: Path): def test_persist_hint_matches_twins(self, tmp_path: Path): """The non-JSON SPECIFY_FEATURE hint must use the '# To persist in your - shell: $env:SPECIFY_FEATURE = ''' form — matching the core + shell: $env:SPECIFY_FEATURE = '' form — matching the core create-new-feature.ps1 twin and the bash/python twins of this script — not the old 'environment variable set to:' wording (the env var is only set in this child process, so the actionable output is the persist hint)."""