diff --git a/commitizen/commands/changelog.py b/commitizen/commands/changelog.py index 854060a867..aab613fffc 100644 --- a/commitizen/commands/changelog.py +++ b/commitizen/commands/changelog.py @@ -137,7 +137,7 @@ def __call__(self): ) start_rev = self._find_incremental_rev(latest_tag_version, tags) - if self.rev_range and self.tag_format: + if self.rev_range: start_rev, end_rev = changelog.get_oldest_and_newest_rev( tags, version=self.rev_range, diff --git a/tests/commands/test_changelog_command.py b/tests/commands/test_changelog_command.py index dc932bd405..c2fafd4552 100644 --- a/tests/commands/test_changelog_command.py +++ b/tests/commands/test_changelog_command.py @@ -659,6 +659,37 @@ def test_changelog_from_rev_single_version_not_found( assert "Could not find a valid revision" in str(excinfo) +@pytest.mark.usefixtures("tmp_commitizen_project") +@pytest.mark.freeze_time("2022-02-13") +def test_changelog_from_rev_range_default_tag_format( + mocker, config_path, changelog_path +): + """Checks that rev_range is calculated with the default (None) tag format""" + # create commit and tag + create_file_and_commit("feat: new file") + testargs = ["cz", "bump", "--yes"] + mocker.patch.object(sys, "argv", testargs) + cli.main() + wait_for_tag() + + create_file_and_commit("feat: after 0.2.0") + create_file_and_commit("feat: another feature") + + testargs = ["cz", "bump", "--yes"] + mocker.patch.object(sys, "argv", testargs) + cli.main() + wait_for_tag() + + testargs = ["cz", "changelog", "0.3.0"] + mocker.patch.object(sys, "argv", testargs) + cli.main() + + with open(changelog_path, "r") as f: + out = f.read() + + assert "new file" not in out + + @pytest.mark.usefixtures("tmp_commitizen_project") @pytest.mark.freeze_time("2022-02-13") def test_changelog_from_rev_range_version_not_found(mocker, config_path):