Skip to content

scm provider cant find current tag with build metadata if matched by legacy_tag_formats #2015

@theinditector

Description

@theinditector

Description

When using version_provider = "scm" and a legacy tag format that matches PEP 440 prerelease tags with local/build metadata, commitizen appears to match the tag but fails to use it as the current tag for bump.

Even if a reachable tag like 1.0.1rc0+gha exists and should be used, cz bump --prerelease rc --build-metadata gha reports that no matching tag could be found.

Steps to reproduce

In some dummy folder:

git init

cat > pyproject.toml <<'EOF'
[tool.commitizen]
version_provider = "scm"
version_scheme = "pep440"
tag_format = "$version"
legacy_tag_formats = [
    '$major.$minor.$patch$prerelease\+.*',
]
EOF

then seed the release history:

echo "a" > file.txt
git add pyproject.toml file.txt
git commit -m "feat: initial"
git tag 1.0.1rc0+gha

then make a follow up commit, and try to make a new release:

echo "b" >> file.txt
git commit -am "fix: bar"
cz bump --prerelease rc --build-metadata gha --get-next

produces:

No tag matching configuration could be found.
Possible causes:
- version in configuration is not the current version
- tag_format or legacy_tag_formats is missing, check them using 'git tag --list'

? Is this the first tag created? No
1.1.0rc0+gha

Current behavior

Even if a tag like 1.0.1rc0+gha` exists, Commitizen reports:

No tag matching configuration could be found.
Possible causes:
- version in configuration is not the current version
- tag_format or legacy_tag_formats is missing, check them using 'git tag --list'

If answering No to “Is this the first tag created?”, Commitizen appears to compute from more history than expected instead of using 1.0.1rc0+gha:

? Is this the first tag created? No
1.1.0rc0+gha

Desired behavior

If the current tag is of the pattern 1.0.1rc0+gha, cz should recognize it and properly bump to 1.0.1rc1+gha when using cz bump --prerelease rc --build-metadata gha --get-next

Screenshots

No response

Environment

Commitizen Version: 4.16.3
Python Version: 3.14.6 (main, Jun 11 2026, 04:03:53) [Clang 22.1.3 ]
Operating System: Linux

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions