Skip to content

Commit 8db7228

Browse files
jawwad-aliclaude
andauthored
fix(scripts): git-ext PowerShell emits the '# To persist' SPECIFY_FEATURE hint (parity) (#3632)
* fix(scripts): git-ext PowerShell emits the '# To persist' SPECIFY_FEATURE hint (parity) The Git extension's create-new-feature-branch.ps1 printed a non-JSON hint 'SPECIFY_FEATURE environment variable set to: <name>', 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 = '<name>''. 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) <noreply@anthropic.com> * docs(test): fix doubled apostrophe in persist-hint test docstring Address review: the docstring rendered the documented output form as '<name>'' (two trailing apostrophes) instead of '<name>'. 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) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a6743ab commit 8db7228

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,12 @@ if (-not $DryRun) {
565565
$env:SPECIFY_FEATURE = $branchName
566566
}
567567

568+
# Build the PowerShell-idiomatic persist hint, mirroring the core
569+
# create-new-feature.ps1 twin (and the bash/python twins of this script), which
570+
# all emit "# To persist in your shell: ...".
571+
$quotedBranchName = "'" + $branchName.Replace("'", "''") + "'"
572+
$featureAssignment = '$env:SPECIFY_FEATURE = ' + $quotedBranchName
573+
568574
if ($Json) {
569575
$obj = [PSCustomObject]@{
570576
BRANCH_NAME = $branchName
@@ -581,6 +587,6 @@ if ($Json) {
581587
Write-Output "BRANCH_NAME: $branchName"
582588
Write-Output "FEATURE_NUM: $featureNum"
583589
if (-not $DryRun) {
584-
Write-Output "SPECIFY_FEATURE environment variable set to: $branchName"
590+
Write-Output "# To persist in your shell: $featureAssignment"
585591
}
586592
}

tests/extensions/git/test_git_extension.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,22 @@ def test_output_omits_has_git_to_match_bash(self, tmp_path: Path):
698698
assert rt.returncode == 0, rt.stderr
699699
assert "HAS_GIT" not in rt.stdout
700700

701+
def test_persist_hint_matches_twins(self, tmp_path: Path):
702+
"""The non-JSON SPECIFY_FEATURE hint must use the '# To persist in your
703+
shell: $env:SPECIFY_FEATURE = '<name>' form — matching the core
704+
create-new-feature.ps1 twin and the bash/python twins of this script —
705+
not the old 'environment variable set to:' wording (the env var is only
706+
set in this child process, so the actionable output is the persist hint)."""
707+
project = _setup_project(tmp_path)
708+
result = _run_pwsh(
709+
"create-new-feature-branch.ps1", project,
710+
"-ShortName", "persist", "Persist hint feature",
711+
)
712+
assert result.returncode == 0, result.stderr
713+
assert "# To persist in your shell:" in result.stdout
714+
assert "$env:SPECIFY_FEATURE = '001-persist'" in result.stdout
715+
assert "environment variable set to:" not in result.stdout
716+
701717
def test_help_documents_branch_prefix(self, tmp_path: Path):
702718
"""-Help documents both template config knobs."""
703719
project = _setup_project(tmp_path)

0 commit comments

Comments
 (0)