Skip to content

Commit b013d24

Browse files
authored
Merge pull request #3202 from jeanplevesque/no-bump-message-priority
fix!: no-bump-message now takes precedence over *-version-bump-message.
2 parents 9998780 + 99692fa commit b013d24

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

BREAKING_CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Unreleased
2+
3+
* When using a commit message that matches **both** `*-version-bump-message` and `no-bump-message`, there is no increment for that commit. In other words, `no-bump-message` now takes precedence over `*-version-bump-message`.
4+
15
## v5.0.0
26

37
* Version numbers in branches other than `release` branches are no longer

docs/input/docs/reference/configuration.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ Used to tell GitVersion not to increment when in Mainline development mode.
191191
Default `\+semver:\s?(none|skip)`, which will match occurrences of `+semver:
192192
none` and `+semver: skip`
193193

194+
When a commit matches **both** the `no-bump-message` **and** any combination of
195+
the `version-bump-message`, `no-bump-message` takes precedence and no increment is applied.
196+
194197
### tag-pre-release-weight
195198

196199
The pre-release weight in case of tagged commits. If the value is not set in the

src/GitVersion.Core.Tests/IntegrationTests/MainlineDevelopmentMode.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,28 @@ public void GivenNoMainThrowsWarning()
523523
exception.ShouldNotBeNull();
524524
exception.Message.ShouldMatch("No branches can be found matching the commit .* in the configured Mainline branches: main, support");
525525
}
526+
527+
[TestCase("feat!: Break stuff +semver: none")]
528+
[TestCase("feat: Add stuff +semver: none")]
529+
[TestCase("fix: Fix stuff +semver: none")]
530+
public void NoBumpMessageTakesPrecedenceOverBumpMessage(string commitMessage)
531+
{
532+
// Same configuration as found here: https://gitversion.net/docs/reference/version-increments#conventional-commit-messages
533+
var conventionalCommitsConfig = new Config
534+
{
535+
VersioningMode = VersioningMode.Mainline,
536+
MajorVersionBumpMessage = "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)",
537+
MinorVersionBumpMessage = "^(feat)(\\([\\w\\s-]*\\))?:",
538+
PatchVersionBumpMessage = "^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:",
539+
};
540+
using var fixture = new EmptyRepositoryFixture();
541+
fixture.MakeATaggedCommit("1.0.0");
542+
543+
fixture.MakeACommit(commitMessage);
544+
545+
fixture.AssertFullSemver("1.0.0", conventionalCommitsConfig);
546+
}
547+
526548
}
527549

528550
internal static class CommitExtensions

src/GitVersion.Core/VersionCalculation/IncrementStrategyFinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ private ICommit[] GetHeadCommits(IGitRepository repo, ICommit? headCommit) =>
134134

135135
private static VersionField? GetIncrementFromMessage(string message, Regex majorRegex, Regex minorRegex, Regex patchRegex, Regex none)
136136
{
137+
if (none.IsMatch(message)) return VersionField.None;
137138
if (majorRegex.IsMatch(message)) return VersionField.Major;
138139
if (minorRegex.IsMatch(message)) return VersionField.Minor;
139140
if (patchRegex.IsMatch(message)) return VersionField.Patch;
140-
if (none.IsMatch(message)) return VersionField.None;
141141
return null;
142142
}
143143

0 commit comments

Comments
 (0)