From 60de537fa8a54789f66a9266e2335f6f5dda7aa9 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Mon, 1 Feb 2021 21:56:49 +0000 Subject: [PATCH] (GH-2456) Testing stuff out just now Will rebase with proper commit message and tests later. --- .../VersionCalculation/NextVersionCalculator.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs index a4d50b0589..7589b16c53 100644 --- a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs @@ -56,6 +56,7 @@ public SemanticVersion FindVersion() } var baseVersion = baseVersionCalculator.GetBaseVersion(); + baseVersion.SemanticVersion.BuildMetaData = mainlineVersionCalculator.CreateVersionBuildMetaData(baseVersion.BaseVersionSource); SemanticVersion semver; if (context.Configuration.VersioningMode == VersioningMode.Mainline) { @@ -63,8 +64,15 @@ public SemanticVersion FindVersion() } 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();