Skip to content

fix: next-version should not require the tag-prefix to parse - #5248

Open
akashchamp wants to merge 1 commit into
GitTools:mainfrom
akashchamp:fix/next-version-tag-prefix
Open

akashchamp wants to merge 1 commit into
GitTools:mainfrom
akashchamp:fix/next-version-tag-prefix

Conversation

@akashchamp

@akashchamp akashchamp commented Sep 24, 2026 •

Copy link
Copy Markdown

Description

next-version is a version, not a tag, so it should never need the
configured tag-prefix stripped from it before parsing. Before this change,
ConfiguredNextVersionVersionStrategy parsed next-version with
SemanticVersion.Parse(nextVersion, Context.Configuration.TagPrefixPattern, ...)
— the same call used for actual Git tags. When tag-prefix was set to
something that does not also accept an empty/optional match (e.g.
tag-prefix: 'package-a/'), that regex requires the prefix to be present at
the start of the string, so any next-version that didn't also start with
the prefix failed to parse.

This PR makes the next-version value parse as-is by passing null instead
of TagPrefixPattern to SemanticVersion.Parse, matching how the rest of the
test suite already parses standalone (non-tag) version strings.

Related Issue

Resolves #5228

Motivation and Context

Reported in #5228: in a monorepo with a non-optional per-package tag-prefix
(e.g. package-a/), setting next-version: 1.4.5 throws
Failed to parse 1.4.5 into a Semantic Version. The only workaround was to
duplicate the prefix into next-version itself (next-version: package-a/1.4.5),
even though next-version is never matched against a Git ref and has no
reason to carry a tag prefix. Maintainer confirmation: "Yea, this makes
sense. Pull requests welcome!" (asbjornu, on the issue).

This is a breaking change for anyone currently using the
next-version: <tag-prefix><version> workaround — that value will now fail
to parse and must be changed to the plain version. Documented in
BREAKING_CHANGES.md under "Unreleased".

How Has This Been Tested?

  • Added MainScenarios.NextVersionInConfigDoesNotRequireTagPrefix, a
    RepositoryFixture integration test that configures
    TagPrefixPattern = "package-a/" and NextVersion = "1.0.0" on the
    develop branch with a single untagged commit, and asserts
    AssertFullSemver("1.0.0-alpha.1", configuration).
    • Confirmed this test reproduces the reported bug: it throws
      GitVersion.WarningException: Failed to parse 1.0.0 into a Semantic Version from SemanticVersion.Parse on the code as it stood before this
      change, and passes after the fix.
  • Ran the full GitVersion.Core.Tests suite (dotnet test src/GitVersion.Core.Tests/GitVersion.Core.Tests.csproj) after the change —
    all tests pass, including the existing ConfiguredNextVersionVersionStrategyTests
    parameterized cases and the CanSpecifyTagPrefixes /
    CanSpecifyTagPrefixesAsRegex / AreTagsNotAdheringToTagPrefixIgnored
    tag-prefix scenarios in MainScenarios, confirming actual Git-tag parsing
    (which still needs tag-prefix stripped) is unaffected.

Screenshots (if appropriate):

N/A (CLI/library behavior change, no UI).

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation. (no docs/ claim about this behavior existed to correct; the breaking-change note lives in BREAKING_CHANGES.md, see above)
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Summary by CodeRabbit

  • Behavior Changes
    • next-version is now parsed as a version value without applying the tag prefix. Update values such as package-a/1.2.3 to 1.2.3 to ensure version calculations use the intended version.
  • Documentation
    • Updated the breaking-changes notes with guidance on the new next-version format.

@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: a9927f3b-21e7-4cb6-9c31-748c76a57596

📥 Commits

Reviewing files that changed from the base of the PR and between f07ae04 and 580c7fe.

📒 Files selected for processing (3)
  • BREAKING_CHANGES.md
  • src/GitVersion.Core.Tests/IntegrationTests/MainScenarios.cs
  • src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/ConfiguredNextVersionVersionStrategy.cs

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The configured next-version value is now parsed without applying tag-prefix. An integration test covers this configuration, and the breaking-change notes document the input format.

Changes

Next-version parsing

Layer / File(s) Summary
Parse and verify configured next-version
src/GitVersion.Core/VersionCalculation/VersionSearchStrategies/ConfiguredNextVersionVersionStrategy.cs, src/GitVersion.Core.Tests/IntegrationTests/MainScenarios.cs, BREAKING_CHANGES.md
The strategy parses next-version without applying tag-prefix. The integration test checks a plain version with a configured prefix. The breaking-change notes describe the updated format and link issue #5228.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: arturcic

Merge Risk: ⚪ Minimal · up to 580c7

Plain next-version values now work with a configured tag prefix, and the migration from prefixed values is documented. No concrete merge-blocking risk is evident.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #5228 requires next-version to parse as a version without the configured tag-prefix. ConfiguredNextVersionVersionStrategy now calls SemanticVersion.Parse with tagPrefixRegex: null. The…
Out of Scope Changes check ✅ Passed The source change implements issue #5228. The integration test verifies the required behavior. The breaking-change note documents the required configuration update for former prefixed values. No unrel…
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: next-version no longer requires the configured tag-prefix for parsing.
Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@asbjornu asbjornu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@mergify

mergify Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

`next-version` is a version, not a tag, so `ConfiguredNextVersionVersionStrategy`
no longer strips the configured `tag-prefix` before parsing it. Previously,
when `tag-prefix` did not accept an empty/optional prefix (e.g.
`tag-prefix: 'package-a/'`), any `next-version` value that didn't also start
with that same prefix failed to parse ("Failed to parse 1.2.3 into a Semantic
Version"), forcing users to write `next-version: package-a/1.2.3` instead of
the plain version.

BREAKING CHANGE: `next-version` values that were prefixed with `tag-prefix` as
a workaround for the parsing failure above will now fail to parse and must be
changed to the plain version instead.

Resolves GitTools#5228
@akashchamp
akashchamp force-pushed the fix/next-version-tag-prefix branch from 580c7fe to f44177f Compare September 25, 2026 18:18
@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ISSUE]: next-version must include tag-prefix

2 participants