Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
}
}
16 changes: 16 additions & 0 deletions tests/extensions/git/test_git_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<name>' 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)
Expand Down