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
4 changes: 4 additions & 0 deletions scripts/powershell/create-new-feature.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ if (-not $DryRun) {
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::WriteAllText($specFile, $content, $utf8NoBom)
} else {
# Match the bash twin (create-new-feature.sh): warn on stderr that no
# spec template was found before creating an empty spec file, so the
# missing-template signal is not silently swallowed on Windows.
[Console]::Error.WriteLine("Warning: Spec template not found; created empty spec file")
New-Item -ItemType File -Path $specFile -Force | Out-Null
}
}
Expand Down
21 changes: 21 additions & 0 deletions tests/test_timestamp_branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,27 @@ def test_explicit_number_zero_is_honored_matching_bash(self, ps_git_repo: Path):
assert data["FEATURE_NUM"] == "000"
assert data["BRANCH_NAME"] == "000-zero"

@pytest.mark.skipif(not _has_pwsh(), reason="pwsh not installed")
def test_missing_spec_template_warns_matching_bash(self, ps_git_repo: Path):
"""When no spec template can be resolved, create-new-feature.ps1 must warn on
stderr (and still create an empty spec file), matching the bash twin's
'Warning: Spec template not found; created empty spec file'. Before the fix
PowerShell created the empty file silently."""
# Remove the template the fixture installs so resolution finds nothing.
(ps_git_repo / ".specify" / "templates" / "spec-template.md").unlink()
script = ps_git_repo / "scripts" / "powershell" / "create-new-feature.ps1"
result = subprocess.run(
["pwsh", "-NoProfile", "-File", str(script),
"-Json", "-ShortName", "no-tmpl", "No template feature"],
cwd=ps_git_repo, capture_output=True, text=True, encoding="utf-8",
)
assert result.returncode == 0, result.stderr
assert "Spec template not found" in result.stderr
# stdout stays parseable JSON and the empty spec file is still created.
data = json.loads(result.stdout)
spec_file = Path(data["SPEC_FILE"])
assert spec_file.is_file()


# ── check_feature_branch Tests ───────────────────────────────────────────────

Expand Down