From 5bf4cf1985815c8a7caa52a3a8477812fb4b105f Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 12 Oct 2023 06:20:27 -0400 Subject: [PATCH] fix: no fragments to collect now exits with 2. #110 --- changelog.d/20231012_061908_nedbat.rst | 7 +++++++ src/scriv/collect.py | 2 +- tests/test_collect.py | 3 ++- 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 changelog.d/20231012_061908_nedbat.rst diff --git a/changelog.d/20231012_061908_nedbat.rst b/changelog.d/20231012_061908_nedbat.rst new file mode 100644 index 0000000..2314db0 --- /dev/null +++ b/changelog.d/20231012_061908_nedbat.rst @@ -0,0 +1,7 @@ +Changed +....... + +- If there are no changelog fragments, ``scriv collect`` now exits with status + code of 2, fixing `issue 110`_. + +.. _issue 110: https://github.com/nedbat/scriv/issues/110 diff --git a/src/scriv/collect.py b/src/scriv/collect.py index 1d05835..7f85d0e 100644 --- a/src/scriv/collect.py +++ b/src/scriv/collect.py @@ -58,7 +58,7 @@ def collect( frags = scriv.fragments_to_combine() if not frags: logger.info("No changelog fragments to collect") - return + sys.exit(2) changelog = scriv.changelog() changelog.read() diff --git a/tests/test_collect.py b/tests/test_collect.py index 1be7cb7..fade884 100644 --- a/tests/test_collect.py +++ b/tests/test_collect.py @@ -434,7 +434,8 @@ def test_no_fragments(cli_invoke, changelog_d, temp_dir, caplog): (changelog_d / "README.rst").write_text("This directory has fragments") (temp_dir / "CHANGELOG.rst").write_text("Not much\n") with freezegun.freeze_time("2020-02-25T15:18:19"): - cli_invoke(["collect"]) + result = cli_invoke(["collect"], expect_ok=False) + assert result.exit_code == 2 changelog_text = (temp_dir / "CHANGELOG.rst").read_text() assert changelog_text == "Not much\n" assert "No changelog fragments to collect" in caplog.text