Skip to content
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

fix(commands/changelog): Fixed issue #561 cz bump could not find the latest version tag with custom tag_format #566

Merged
merged 1 commit into from
Sep 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions commitizen/commands/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions tests/commands/test_changelog_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)