Skip to content

git.get_commits error check #540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 21, 2022
Prev Previous commit
Next Next commit
test(changelog): code coverage improvements
  • Loading branch information
bhelgs committed Aug 14, 2022
commit d5b67b0c7ae9a14b79442adfab32c106b1473970
4 changes: 0 additions & 4 deletions commitizen/commands/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
from commitizen.git import GitTag, smart_open


def similar(a, b):
return SequenceMatcher(None, a, b).ratio()


class Changelog:
"""Generate a changelog based on the commit history."""

Expand Down
21 changes: 21 additions & 0 deletions tests/commands/test_changelog_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,15 @@ def test_changelog_without_revision(mocker, tmp_commitizen_project):
cli.main()


def test_changelog_incremental_with_revision(mocker):
"""combining incremental with a revision doesn't make sense"""
testargs = ["cz", "changelog", "--incremental", "0.2.0"]
mocker.patch.object(sys, "argv", testargs)

with pytest.raises(NotAllowed):
cli.main()


def test_changelog_with_different_tag_name_and_changelog_content(
mocker, tmp_commitizen_project
):
Expand Down Expand Up @@ -918,3 +927,15 @@ def test_changelog_with_customized_change_type_order(
out = f.read()

file_regression.check(out, extension=".md")


@pytest.mark.usefixtures("tmp_commitizen_project")
def test_empty_commit_list(mocker):
create_file_and_commit("feat: a new world")

# test changelog properly handles when no commits are found for the revision
mocker.patch("commitizen.git.get_commits", return_value=[])
testargs = ["cz", "changelog"]
mocker.patch.object(sys, "argv", testargs)
with pytest.raises(NoCommitsFoundError):
cli.main()