Skip to content

fix #3071 consider commit messages since latest tag only #3078

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 19, 2022
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