diff --git a/CHANGELOG.md b/CHANGELOG.md index df34c93..8366cb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to diffly are documented here. The format follows [Keep a Ch ### Fixed - Fast keystroke bursts in the interactive review menu register every press: escape sequences stop at their terminator instead of swallowing neighboring keys. +- `diffly setup` no longer runs the update check twice in a row (once in `main()` and again inside the wizard it launches). - Pressing an arrow key in the interactive review menu no longer crashes with `NameError: name '_read_escape_sequence' is not defined`; the escape-sequence reader is defined again and a lone Escape still exits without blocking. ## [1.0.0] - 2026-08-22 diff --git a/src/diffly_cli/cli.py b/src/diffly_cli/cli.py index 20f4bcf..752a989 100644 --- a/src/diffly_cli/cli.py +++ b/src/diffly_cli/cli.py @@ -907,7 +907,9 @@ def main(argv: list[str] | None = None) -> int: if not effective_argv: return run_wizard(parser) args = parser.parse_args(effective_argv) - if args.command not in ("update", "version", "help", "doctor"): + # `setup` ends in the wizard, which runs its own update check; checking + # here too would prompt the user twice in a row. + if args.command not in ("update", "version", "help", "doctor", "setup"): _check_and_prompt_update() return args.func(args) diff --git a/tests/test_regressions.py b/tests/test_regressions.py index d51d481..1cf6c85 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -398,3 +398,20 @@ def test_escape_sequence_reader_consumes_exactly_one_sequence(monkeypatch): finally: os.close(read_fd) os.close(write_fd) + + +def test_setup_delegates_the_update_check_to_the_wizard(monkeypatch): + """Regression: `diffly setup` used to run the update check twice — once in + main() and again inside the wizard it launches — prompting back to back.""" + import diffly_cli.cli as cli + + calls: list[str] = [] + monkeypatch.setattr(cli, "_check_and_prompt_update", lambda: calls.append("check")) + monkeypatch.setattr(cli, "run_setup", lambda args: 0) + assert cli.main(["setup"]) == 0 + assert calls == [] + + calls.clear() + monkeypatch.setattr(cli, "run_pr", lambda args: 0) + assert cli.main(["pr", "acme/demo", "1"]) == 0 + assert calls == ["check"]