From 7d68fd8b5579a6fb5188f0c95af3879b24bc194f Mon Sep 17 00:00:00 2001 From: Shubham Padkonde Date: Sat, 24 Oct 2026 04:30:02 +0530 Subject: [PATCH] fix: preserve feature numbering during reinitialization Assisted-by: Codex (model: GPT-6, autonomous) --- src/specify_cli/command_init.py | 2 +- tests/specify_cli/test_command_init.py | 29 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/specify_cli/command_init.py b/src/specify_cli/command_init.py index 7d1536d4ba..31fa2277dd 100644 --- a/src/specify_cli/command_init.py +++ b/src/specify_cli/command_init.py @@ -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, } diff --git a/tests/specify_cli/test_command_init.py b/tests/specify_cli/test_command_init.py index e353445870..f932167cdf 100644 --- a/tests/specify_cli/test_command_init.py +++ b/tests/specify_cli/test_command_init.py @@ -17,6 +17,7 @@ from __future__ import annotations import importlib +import json import os import re import subprocess @@ -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."""