Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions BREAKING_CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Unreleased

* 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`.

## v5.0.0

* Version numbers in branches other than `release` branches are no longer
Expand Down
3 changes: 3 additions & 0 deletions docs/input/docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ Used to tell GitVersion not to increment when in Mainline development mode.
Default `\+semver:\s?(none|skip)`, which will match occurrences of `+semver:
none` and `+semver: skip`

When a commit matches **both** the `no-bump-message` **and** any combination of
the `version-bump-message`, `no-bump-message` takes precedence and no increment is applied.

### tag-pre-release-weight

The pre-release weight in case of tagged commits. If the value is not set in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,28 @@ public void GivenNoMainThrowsWarning()
exception.ShouldNotBeNull();
exception.Message.ShouldMatch("No branches can be found matching the commit .* in the configured Mainline branches: main, support");
}

[TestCase("feat!: Break stuff +semver: none")]
[TestCase("feat: Add stuff +semver: none")]
[TestCase("fix: Fix stuff +semver: none")]
public void NoBumpMessageTakesPrecedenceOverBumpMessage(string commitMessage)
{
// Same configuration as found here: https://gitversion.net/docs/reference/version-increments#conventional-commit-messages
var conventionalCommitsConfig = new Config
{
VersioningMode = VersioningMode.Mainline,
MajorVersionBumpMessage = "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)",
MinorVersionBumpMessage = "^(feat)(\\([\\w\\s-]*\\))?:",
PatchVersionBumpMessage = "^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s-]*\\))?:",
};
using var fixture = new EmptyRepositoryFixture();
fixture.MakeATaggedCommit("1.0.0");

fixture.MakeACommit(commitMessage);

fixture.AssertFullSemver("1.0.0", conventionalCommitsConfig);
}

}

internal static class CommitExtensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ private ICommit[] GetHeadCommits(IGitRepository repo, ICommit? headCommit) =>

private static VersionField? GetIncrementFromMessage(string message, Regex majorRegex, Regex minorRegex, Regex patchRegex, Regex none)
{
if (none.IsMatch(message)) return VersionField.None;
if (majorRegex.IsMatch(message)) return VersionField.Major;
if (minorRegex.IsMatch(message)) return VersionField.Minor;
if (patchRegex.IsMatch(message)) return VersionField.Patch;
if (none.IsMatch(message)) return VersionField.None;
return null;
}

Expand Down