Repository navigation
fix(scm-provider): prefer full version over floating tags - #2116
Merged
Merged
Conversation
Motivation: With tags v1.0.0, v1.0 and v1 on one commit, the scm version provider returned "1.0". The three versions compare equal, and max() kept the first one, which is the newest tag by date. The patch part was dropped from the project version. Approach: Break ties between equal versions by choosing the longest spelling, so 1.0.0 wins over 1.0 and 1. Ordering of unequal versions is unchanged. Validation: `uv run pytest -n0` passed (1331 passed, 2 skipped, 2 xfailed). The new test fails without the change and passes with it. `ruff check`, `ruff format --check` and `mypy commitizen/providers` pass. `uv run poe all` was not run in full. Impact: Only affects `version_provider = "scm"` when equal-valued tags with different lengths exist. Only the version printed or used was wrong; nothing else changed. Report: commitizen-tools#1863 Assisted By: AI Signed-off-by: Pujitha Paladugu <10557236+pujitha24@users.noreply.github.com> Assisted-by: claude-sonnet-5-5 (via Claude Code)
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2116 +/- ##
=======================================
Coverage 98.28% 98.28%
=======================================
Files 61 61
Lines 2864 2864
=======================================
Hits 2815 2815
Misses 49 49 ☔ View full report in Codecov by Harness. |
woile
approved these changes
Oct 24, 2026
Member
|
Thanks! 🎉 |
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
Fix
version_provider = "scm"returning1.0instead of1.0.0when floating tags (v1.0,v1) exist next tov1.0.0. The tags compare equal andmax()kept the newest one. Now the longest spelling wins among equal versions.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 testspytest(all pass),ruff check,ruff format --check,mypy commitizen/providers. Not the fullpoe all.Documentation Changes
uv run poe doclocally to ensure the documentation pages renders correctlyExpected Behavior
cz version --projectprints1.0.0when tagsv1.0.0,v1.0andv1exist.Steps to Test This Pull Request
uv run pytest tests/providers/test_scm_provider.pytest_scm_provider_prefers_full_version_over_floating_tagsfails on master and passes with this change.Additional Context
Fixes #1863
AI assistance: this change was drafted with Claude Code.