Skip to content

Commit

Permalink
fix: no fragments to collect now exits with 2. #110
Browse files Browse the repository at this point in the history
  • Loading branch information
Ned Batchelder committed Oct 12, 2023
1 parent 951c0f8 commit 5bf4cf1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions changelog.d/20231012_061908_nedbat.rst
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/scriv/collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion tests/test_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5bf4cf1

Please sign in to comment.