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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using GitVersion.Core.Tests.Helpers;
using GitVersion.Model.Configuration;
using GitVersion.VersionCalculation;
using LibGit2Sharp;
using NUnit.Framework;

namespace GitVersion.Core.Tests.IntegrationTests;
Expand Down Expand Up @@ -48,6 +49,23 @@ public void CanUseCommitMessagesToBumpVersion()
fixture.AssertFullSemver("2.0.0+2");
}

[Test]
public void CanUseCommitMessagesToBumpVersion_TagTakesPriority()
{
using var fixture = new EmptyRepositoryFixture();
var repo = fixture.Repository;

repo.MakeATaggedCommit("1.0.0");
repo.MakeACommit("+semver:major");
fixture.AssertFullSemver("2.0.0+1");

repo.ApplyTag("1.1.0");
fixture.AssertFullSemver("1.1.0");

repo.MakeACommit();
fixture.AssertFullSemver("1.1.1+1");
}

[Theory]
[TestCase("build: Cleaned up various things", "1.0.1")]
[TestCase("build: Cleaned up various things\n\nSome descriptive text", "1.0.1")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ public class IncrementStrategyFinder : IIncrementStrategyFinder

var commits = GetIntermediateCommits(repository, baseCommit, context.CurrentCommit);

// consider commit messages since latest tag only (see #3071)
var tags = new HashSet<string?>(repository.Tags.Select(t => t.TargetSha));
commits = commits
.Reverse()
.TakeWhile(x => !tags.Contains(x.Sha))
.Reverse();

if (context.Configuration.CommitMessageIncrementing == CommitMessageIncrementMode.MergeMessageOnly)
{
commits = commits.Where(c => c.Parents.Count() > 1);
Expand Down