Skip to content

Commit e4fa19c

Browse files
committed
test(changelog): fixes logic issue made evident by latest fix(git) commit
Exception is raised by git error: "fatal: your current branch 'master' does not have any commits yet". This response is more informative than the original "No commits found" exception and the "fail fast" logic is a bit easier to follow.
1 parent 0d5bf84 commit e4fa19c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

tests/commands/test_changelog_command.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from commitizen.commands.changelog import Changelog
88
from commitizen.exceptions import (
99
DryRunExit,
10+
GitCommandError,
1011
NoCommitsFoundError,
1112
NoRevisionError,
1213
NotAGitProjectError,
@@ -20,10 +21,12 @@ def test_changelog_on_empty_project(mocker):
2021
testargs = ["cz", "changelog", "--dry-run"]
2122
mocker.patch.object(sys, "argv", testargs)
2223

23-
with pytest.raises(NoCommitsFoundError) as excinfo:
24+
with pytest.raises(GitCommandError):
2425
cli.main()
2526

26-
assert "No commits found" in str(excinfo)
27+
# git will error out with something like:
28+
# "your current branch 'XYZ' does not have any commits yet"
29+
# is it wise to assert the exception contains a message like this?
2730

2831

2932
@pytest.mark.usefixtures("tmp_commitizen_project")

0 commit comments

Comments
 (0)