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