From 92d9df4a16fe2f864e9645b8c2f0804ff0cf3933 Mon Sep 17 00:00:00 2001 From: Vivaan Dhawan <150339722+VIVAAN-DHAWAN@users.noreply.github.com> Date: Sun, 23 Aug 2026 10:29:32 +0530 Subject: [PATCH] Stop running the update check twice for diffly setup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main() ran _check_and_prompt_update for the setup command, and the setup walkthrough then launches the wizard, which performs its own check — so users with a pending release faced the same prompt two times in a row. Exclude setup like update/version/help/doctor and let the wizard own the check. --- CHANGELOG.md | 1 + src/diffly_cli/cli.py | 4 +++- tests/test_regressions.py | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) 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"]