Skip to content

cz bump could not find the latest version tag to do incremental changelog when there is custom tag_format #561

Closed
@ssiuhk

Description

@ssiuhk

Description

cz bump could not find the latest version tag to do incremental changelog when there is custom tag_format in git tags for versions

Steps to reproduce

  1. Create a release 1.0.0
  2. Create a custom git tag SOME_TAG_PREFIX_1.0.0
  3. Add a new feature commit
  4. Run cz bump to try to determine new version

Current behavior

cz bump cannot find tag to do an incremental changelog

$ cat .cz.toml | grep tag_format
tag_format = "SOME_TAG_PREFIX_$version"
$ git tag
SOME_TAG_PREFIX_1.0.0

$ git log
commit 11ba99fd2907be046e814662e3057c4bdd9f3db0 (HEAD -> master)
Author: Sam SIU <23556929+ssiuhk@users.noreply.github.com>
Date:   Fri Aug 19 19:35:08 2022 +0000

    feat(Testing): Testing something

commit db20a16f6ed45ef1470b131f65c9006b094c4a58 (tag: SOME_TAG_PREFIX_1.0.0)
Author: Sam SIU <23556929+ssiuhk@users.noreply.github.com>
Date:   Fri Aug 19 18:54:18 2022 +0000

    First release
$ cz bump --dry-run --changelog
bump: version 1.0.0 → 1.1.0
tag to create: SOME_TAG_PREFIX_1.1.0
increment detected: MINOR

No tag found to do an incremental changelog

Desired behavior

cz bump should identify the custom git tag and create an incremental changelog

$ cz bump --dry-run --changelog
bump: version 1.0.0 → 1.1.0
tag to create: SOME_TAG_PREFIX_1.1.0
increment detected: MINOR

## SOME_TAG_PREFIX_1.1.0 (2022-08-19)

### Feat

- **Testing**: Testing something

Screenshots

No response

Environment

commitizen/commands/changelog.py
_find_incremental_rev()

$ cz bump --dry-run --changelog
bump: version 1.0.0 → 1.1.0
tag to create: SOME_TAG_PREFIX_1.1.0
increment detected: MINOR

> commitizen/commands/changelog.py(71)_find_incremental_rev()
-> tag_ratio = map(
(Pdb) n
> commitizen/commands/changelog.py(72)_find_incremental_rev()
-> lambda tag: (SequenceMatcher(None, latest_version, tag.name).ratio(), tag),
(Pdb) n
> commitizen/commands/changelog.py(73)_find_incremental_rev()
-> tags,
(Pdb) latest_version
'1.0.0'
(Pdb) tags
[GitTag('SOME_TAG_PREFIX_1.0.0', 'db20a16f6ed45ef1470b131f65c9006b094c4a58', '2022-08-19')]
(Pdb) n
> commitizen/commands/changelog.py(75)_find_incremental_rev()
-> try:
(Pdb) n
> commitizen/commands/changelog.py(76)_find_incremental_rev()
-> score, tag = max(tag_ratio, key=itemgetter(0))
(Pdb) n
> commitizen/commands/changelog.py(79)_find_incremental_rev()
-> if score < SIMILARITY_THRESHOLD:
(Pdb) score
0.38461538461538464

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions