Skip to content

Commit 8a3c7eb

Browse files
committed
Attempt to fix issue where commit message is counted twice.
When multiple base versions will result in the same semantic version, the oldest is selected for commit counting. The same base version commit is used to find intermediate commits for commit mesage increments. The attempt here is to use the oldest base version also for the semantic version such that the commit message increments are not done on a semver from another base version.
1 parent e2de92b commit 8a3c7eb

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Diagnostics;
34
using GitTools;
45
using GitTools.Testing;
@@ -375,7 +376,7 @@ public void ReleaseBranchShouldUseBranchNameVersionDespiteBumpInPreviousCommit()
375376

376377
Commands.Checkout(fixture.Repository, fixture.Repository.CreateBranch("release/2.0"));
377378

378-
fixture.AssertFullSemver("2.0.0-beta.1+0");
379+
fixture.AssertFullSemver("2.0.0-beta.1+2");
379380
}
380381
}
381382
}

src/GitVersionCore/VersionCalculation/BaseVersionCalculator.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public BaseVersion GetBaseVersion(GitVersionContext context)
5151
BaseVersion baseVersionWithOldestSource;
5252
if (matchingVersionsOnceIncremented.Any())
5353
{
54-
baseVersionWithOldestSource = matchingVersionsOnceIncremented.Aggregate((v1, v2) => v1.Version.BaseVersionSource.Committer.When < v2.Version.BaseVersionSource.Committer.When ? v1 : v2).Version;
54+
var oldest = matchingVersionsOnceIncremented.Aggregate((v1, v2) => v1.Version.BaseVersionSource.Committer.When < v2.Version.BaseVersionSource.Committer.When ? v1 : v2);
55+
baseVersionWithOldestSource = oldest.Version;
56+
maxVersion = oldest;
5557
Logger.WriteInfo(string.Format(
5658
"Found multiple base versions which will produce the same SemVer ({0}), taking oldest source for commit counting ({1})",
5759
maxVersion.IncrementedVersion,

0 commit comments

Comments
 (0)