Skip to content

Commit

Permalink
(GH-2456) Fix issue asserting tagged commit on CI
Browse files Browse the repository at this point in the history
Ensure that an increment of the version number only occurs when the
sha of the commit is different from the base version sha.
  • Loading branch information
gep13 authored and arturcic committed Feb 6, 2021
1 parent 6c8e199 commit d20b537
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,23 @@ public SemanticVersion FindVersion()
}

var baseVersion = baseVersionCalculator.GetBaseVersion();
baseVersion.SemanticVersion.BuildMetaData = mainlineVersionCalculator.CreateVersionBuildMetaData(baseVersion.BaseVersionSource);
SemanticVersion semver;
if (context.Configuration.VersioningMode == VersioningMode.Mainline)
{
semver = mainlineVersionCalculator.FindMainlineModeVersion(baseVersion);
}
else
{
semver = PerformIncrement(baseVersion);
semver.BuildMetaData = mainlineVersionCalculator.CreateVersionBuildMetaData(baseVersion.BaseVersionSource);
if (taggedSemanticVersion?.BuildMetaData == null || (taggedSemanticVersion.BuildMetaData.Sha != baseVersion.SemanticVersion.BuildMetaData.Sha))
{
semver = PerformIncrement(baseVersion);
semver.BuildMetaData = mainlineVersionCalculator.CreateVersionBuildMetaData(baseVersion.BaseVersionSource);
}
else
{
semver = baseVersion.SemanticVersion;
}
}

var hasPreReleaseTag = semver.PreReleaseTag.HasTag();
Expand Down

0 comments on commit d20b537

Please sign in to comment.