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
2 changes: 1 addition & 1 deletion src/specify_cli/command_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ def init(
"integration": resolved_integration.key,
"here": here,
"script": selected_script,
"feature_numbering": "sequential",
"feature_numbering": previous_init_options.get("feature_numbering", "sequential"),
"speckit_version": get_speckit_version(),
"allow_symlinks": allow_symlinks,
}
Expand Down
29 changes: 29 additions & 0 deletions tests/specify_cli/test_command_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from __future__ import annotations

import importlib
import json
import os
import re
import subprocess
Expand Down Expand Up @@ -93,6 +94,34 @@ def _init(tmp_path: Path, name: str):
os.chdir(previous)


@pytest.mark.parametrize("numbering", ["timestamp", "sequential", None])
def test_reinit_preserves_feature_numbering(tmp_path: Path, monkeypatch, numbering):
result = _init(tmp_path, "proj")
assert result.exit_code == 0, _strip(result.stdout)
project = tmp_path / "proj"
options_path = project / ".specify" / "init-options.json"
options = json.loads(options_path.read_text(encoding="utf-8"))
assert options["feature_numbering"] == "sequential"
if numbering is None:
options.pop("feature_numbering")
else:
options["feature_numbering"] = numbering
options["custom_setting"] = "keep me"
options_path.write_text(json.dumps(options), encoding="utf-8")

monkeypatch.chdir(project)
result = CliRunner().invoke(app, [
"init", "--here", "--force", "--integration", "generic",
"--integration-options", "--commands-dir .agent/commands",
"--script", "sh", "--non-interactive", "--ignore-agent-tools", "--offline",
])
assert result.exit_code == 0, _strip(result.stdout)
updated = json.loads(options_path.read_text(encoding="utf-8"))
assert updated["feature_numbering"] == (numbering or "sequential")
assert updated["custom_setting"] == "keep me"
assert updated["here"] is True


@pytest.mark.parametrize("name", ["proj [v2]", "my[bold]app"])
def test_next_steps_cd_shows_the_real_project_name(tmp_path: Path, name: str):
"""The `cd` line must name the directory that was actually created."""
Expand Down
Loading