fix(tags): find current tag matched by a regex-only legacy tag format - #2089
Open
ethanstoner wants to merge 1 commit into
Open
ethanstoner wants to merge 1 commit into
ethanstoner wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2089 +/- ##
=======================================
Coverage 98.26% 98.26%
=======================================
Files 61 61
Lines 2829 2829
=======================================
Hits 2780 2780
Misses 49 49 ☔ View full report in Codecov by Harness. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #2015
With
version_provider = "scm"and a legacy tag format such as'$major.$minor.$patch$prerelease\+.*', a tag like1.0.1rc0+ghais recognised and its version is extracted as1.0.1rc0.cz bumpthen callsTagRules.find_tag_for, which only compares tag names againstnormalize_tag(version, fmt)for each format. The\+.*part is regex-only and can't be rendered back into a tag name, so nothing matched. Bump reported "No tag matching configuration could be found." and computed the next version from the whole history.Fix: when no tag name matches exactly,
find_tag_fornow falls back to tags whose extracted version equals the requested version. A small private helper,_parse_tag_versions, yields(version, tag)pairs and skips tags that fail to parse. The existing partial-version branch now uses it too, replacing its inline try/except loop.Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines
Code Changes
uv run poe alllocally to ensure this change passes linter check and testsExpected Behavior
Using the reproduction from the issue,
cz bump --prerelease rc --build-metadata gha --get-nextfinds1.0.1rc0+ghaas the current tag and prints1.0.1rc1+gha. Before this change it printed1.1.0rc0+gha.Steps to Test This Pull Request
uv run pytest tests/test_tags.py tests/commands/test_bump_command.py -k "regex_only_legacy_tag_format or legacy_tag_with_build_metadata". Both new tests fail on master and pass with this change.tag_format = "$version", the legacy format above, tag1.0.1rc0+gha, then afix:commit) and runcz bump --prerelease rc --build-metadata gha --get-next. On master the output is1.1.0rc0+gha; on this branch it is1.0.1rc1+gha.uv run poe allpasses locally (1311 passed, 2 skipped, 2 xfailed;commitizen/tags.pyat 100% coverage).Additional Context
The fallback only runs when no exact tag name matches, so existing lookups are unchanged. It can also find tags that differ only in how the version is written (e.g.
1.0.0-rc0for1.0.0rc0). If several tags share a version but carry different build metadata, the existing "Multiple tags found" warning is emitted and the first tag is used, same as for exact matches.