diff --git a/commitizen/commands/changelog.py b/commitizen/commands/changelog.py index 0520b95257..854060a867 100644 --- a/commitizen/commands/changelog.py +++ b/commitizen/commands/changelog.py @@ -3,7 +3,7 @@ from operator import itemgetter from typing import Callable, Dict, List, Optional -from commitizen import changelog, defaults, factory, git, out +from commitizen import bump, changelog, defaults, factory, git, out from commitizen.config import BaseConfig from commitizen.exceptions import ( DryRunExit, @@ -132,7 +132,10 @@ def __call__(self): changelog_meta = changelog.get_metadata(self.file_name) latest_version = changelog_meta.get("latest_version") if latest_version: - start_rev = self._find_incremental_rev(latest_version, tags) + latest_tag_version: str = bump.normalize_tag( + latest_version, tag_format=self.tag_format + ) + start_rev = self._find_incremental_rev(latest_tag_version, tags) if self.rev_range and self.tag_format: start_rev, end_rev = changelog.get_oldest_and_newest_rev( diff --git a/tests/commands/test_changelog_command.py b/tests/commands/test_changelog_command.py index 030d53824d..dc932bd405 100644 --- a/tests/commands/test_changelog_command.py +++ b/tests/commands/test_changelog_command.py @@ -142,14 +142,14 @@ def test_changelog_incremental_angular_sample( ): with open(changelog_path, "w") as f: f.write( - "# [10.0.0-next.3](https://github.com/angular/angular/compare/10.0.0-next.2...10.0.0-next.3) (2020-04-22)\n" + "# [10.0.0-rc.3](https://github.com/angular/angular/compare/10.0.0-rc.2...10.0.0-rc.3) (2020-04-22)\n" "\n" "### Bug Fixes" "\n" "* **common:** format day-periods that cross midnight ([#36611](https://github.com/angular/angular/issues/36611)) ([c6e5fc4](https://github.com/angular/angular/commit/c6e5fc4)), closes [#36566](https://github.com/angular/angular/issues/36566)\n" ) create_file_and_commit("irrelevant commit") - git.tag("10.0.0-next.3") + git.tag("10.0.0-rc.3") create_file_and_commit("feat: add new output") create_file_and_commit("fix: output glitch") diff --git a/tests/commands/test_changelog_command/test_changelog_incremental_angular_sample.md b/tests/commands/test_changelog_command/test_changelog_incremental_angular_sample.md index ea4c57c974..83bfdfe852 100644 --- a/tests/commands/test_changelog_command/test_changelog_incremental_angular_sample.md +++ b/tests/commands/test_changelog_command/test_changelog_incremental_angular_sample.md @@ -10,7 +10,7 @@ - mama gotta work - output glitch -# [10.0.0-next.3](https://github.com/angular/angular/compare/10.0.0-next.2...10.0.0-next.3) (2020-04-22) +# [10.0.0-rc.3](https://github.com/angular/angular/compare/10.0.0-rc.2...10.0.0-rc.3) (2020-04-22) ### Bug Fixes * **common:** format day-periods that cross midnight ([#36611](https://github.com/angular/angular/issues/36611)) ([c6e5fc4](https://github.com/angular/angular/commit/c6e5fc4)), closes [#36566](https://github.com/angular/angular/issues/36566)