💫 Toolkit to help you get started with SDD or any other process!
fix(powershell): preserve plans in literal feature paths (#4956)
Aurantium51b6d170aa73
diff --git a/scripts/powershell/setup-plan.ps1 b/scripts/powershell/setup-plan.ps1index 036a54e4d..0d888584a 100644--- a/scripts/powershell/setup-plan.ps1+++ b/scripts/powershell/setup-plan.ps1@@ -39,7 +39,7 @@ if (-not $paths) {New-Item -ItemType Directory -Path $paths.FEATURE_DIR -Force | Out-Null# Copy plan template if plan doesn't already exist-if (Test-Path $paths.IMPL_PLAN -PathType Leaf) {+if (Test-Path -LiteralPath $paths.IMPL_PLAN -PathType Leaf) {if ($Json) {[Console]::Error.WriteLine("Plan already exists at $($paths.IMPL_PLAN), skipping template copy")} else {diff --git a/tests/test_setup_plan_no_overwrite.py b/tests/test_setup_plan_no_overwrite.pyindex b965551f2..c92f038f2 100644--- a/tests/test_setup_plan_no_overwrite.py+++ b/tests/test_setup_plan_no_overwrite.py@@ -200,9 +200,11 @@ def test_ps_setup_plan_creates_plan_when_missing(plan_repo: Path) -> None:@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")-def test_ps_setup_plan_preserves_existing_plan(plan_repo: Path) -> None:[email protected]("feature_name", ["001-my-feature", "001-my-feature [v2]"])+def test_ps_setup_plan_preserves_existing_plan(plan_repo: Path, feature_name: str) -> None:"""Rerun must not overwrite an existing plan.md."""- feat = plan_repo / "specs" / "001-my-feature"+ _write_feature_json(plan_repo, f"specs/{feature_name}")+ feat = plan_repo / "specs" / feature_namefeat.mkdir(parents=True)existing_content = "# My carefully authored plan\n\nDo not overwrite me.\n"(feat / "plan.md").write_text(existing_content, encoding="utf-8")@@ -226,6 +228,35 @@ def test_ps_setup_plan_preserves_existing_plan(plan_repo: Path) -> None:assert "already exists" in result.stderr[email protected](not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")+def test_ps_setup_plan_does_not_match_another_features_plan(plan_repo: Path) -> None:+ """A wildcard-shaped feature path must not match a neighboring plan."""+ feature_name = "001-my-feature [v2]"+ _write_feature_json(plan_repo, f"specs/{feature_name}")+ neighbor = plan_repo / "specs" / "001-my-feature v"+ neighbor.mkdir(parents=True)+ existing_content = "# Another feature's plan\n"+ (neighbor / "plan.md").write_text(existing_content, encoding="utf-8")++ script = plan_repo / ".specify" / "scripts" / "powershell" / "setup-plan.ps1"+ exe = "pwsh" if HAS_PWSH else _WINDOWS_POWERSHELL+ result = subprocess.run(+ [exe, "-NoProfile", "-File", str(script), "-Json"],+ cwd=plan_repo,+ capture_output=True,+ text=True,+ check=False,+ env=_clean_env(),+ )+ assert result.returncode == 0, result.stderr+ data = json.loads(result.stdout)+ plan_path = plan_repo / "specs" / feature_name / "plan.md"+ assert Path(data["IMPL_PLAN"]) == plan_path+ assert plan_path.read_text(encoding="utf-8") == PLAN_TEMPLATE.read_text(encoding="utf-8")+ assert (neighbor / "plan.md").read_text(encoding="utf-8") == existing_content+ assert "Copied plan template" in result.stderr++@pytest.mark.skipif(not (HAS_PWSH or _WINDOWS_POWERSHELL), reason="no PowerShell available")def test_ps_setup_plan_copied_message_on_stderr_in_json_mode(plan_repo: Path) -> None:"""First run in -Json mode must emit 'Copied plan template' on stderr (matching