From c31abe3f2efb17649fd1c59c60ca836557dd90d3 Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Mon, 24 Oct 2022 19:14:52 +0200 Subject: [PATCH 01/11] Fix CanTakePreReleaseVersionFromReleasesBranchWithNumericPreReleaseTag test Because release branch has 'beta' prefix configured. --- .../IntegrationTests/ReleaseBranchScenarios.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/GitVersion.Core.Tests/IntegrationTests/ReleaseBranchScenarios.cs b/src/GitVersion.Core.Tests/IntegrationTests/ReleaseBranchScenarios.cs index 6a53ab50a3..3736112c9c 100644 --- a/src/GitVersion.Core.Tests/IntegrationTests/ReleaseBranchScenarios.cs +++ b/src/GitVersion.Core.Tests/IntegrationTests/ReleaseBranchScenarios.cs @@ -88,10 +88,10 @@ public void CanTakePreReleaseVersionFromReleasesBranchWithNumericPreReleaseTag() fixture.Repository.MakeCommits(5); fixture.Repository.CreateBranch("releases/2.0.0"); fixture.Checkout("releases/2.0.0"); - fixture.Repository.ApplyTag("v2.0.0-1"); + fixture.Repository.ApplyTag("v2.0.0-beta.1"); var variables = fixture.GetVersion(); - Assert.AreEqual("2.0.0-1", variables.FullSemVer); + Assert.AreEqual("2.0.0-beta.1", variables.FullSemVer); } [Test] From e1510522a91a56ea6a1b2650fc5f7949895d00bb Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Mon, 24 Oct 2022 21:23:21 +0200 Subject: [PATCH 02/11] Rearrange actions in the UpdatePreReleaseTag method To improve readability. --- .../VersionCalculation/NextVersionCalculator.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs index cd418552cc..e7a24b2be2 100644 --- a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs @@ -126,19 +126,21 @@ private void UpdatePreReleaseTag(EffectiveBranchConfiguration configuration, Sem return; } - long? number = null; - // TODO: Please update the pre release-tag in the IVersionStrategy implementation. var lastTag = this.repositoryStore .GetVersionTagsOnBranch(Context.CurrentBranch, Context.Configuration.LabelPrefix, Context.Configuration.SemanticVersionFormat) .FirstOrDefault(v => v.PreReleaseTag?.Name?.IsEquivalentTo(tagToUse) == true); + long? number = null; + if (lastTag != null && MajorMinorPatchEqual(lastTag, semanticVersion) && lastTag.HasPreReleaseTagWithLabel) { number = lastTag.PreReleaseTag?.Number + 1; } - - number ??= 1; + else + { + number = 1; + } semanticVersion.PreReleaseTag = new SemanticVersionPreReleaseTag(tagToUse, number); } From 67e6722a2c24bb45d964957249b3d1fb5d8ab0d2 Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Mon, 24 Oct 2022 21:24:14 +0200 Subject: [PATCH 03/11] Rename UpdatePreReleaseTag variables To make the method logic more understandable. --- .../NextVersionCalculator.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs index e7a24b2be2..2db32de5a2 100644 --- a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs @@ -118,31 +118,31 @@ public virtual NextVersion FindVersion() private void UpdatePreReleaseTag(EffectiveBranchConfiguration configuration, SemanticVersion semanticVersion, string? branchNameOverride) { - var tagToUse = configuration.Value.GetBranchSpecificTag(this.log, Context.CurrentBranch.Name.Friendly, branchNameOverride); + var preReleaseTagName = configuration.Value.GetBranchSpecificTag(this.log, Context.CurrentBranch.Name.Friendly, branchNameOverride); - if (configuration.Value.IsMainline && tagToUse.IsEmpty()) + if (configuration.Value.IsMainline && preReleaseTagName.IsEmpty()) { - semanticVersion.PreReleaseTag = new SemanticVersionPreReleaseTag(tagToUse, null); + semanticVersion.PreReleaseTag = new SemanticVersionPreReleaseTag(preReleaseTagName, null); return; } // TODO: Please update the pre release-tag in the IVersionStrategy implementation. - var lastTag = this.repositoryStore - .GetVersionTagsOnBranch(Context.CurrentBranch, Context.Configuration.LabelPrefix, Context.Configuration.SemanticVersionFormat) - .FirstOrDefault(v => v.PreReleaseTag?.Name?.IsEquivalentTo(tagToUse) == true); + var lastPrefixedSemver = this.repositoryStore + .GetVersionTagsOnBranch(Context.CurrentBranch, Context.Configuration.LabelPrefix) + .FirstOrDefault(v => v.PreReleaseTag?.Name?.IsEquivalentTo(preReleaseTagName) == true); long? number = null; - if (lastTag != null && MajorMinorPatchEqual(lastTag, semanticVersion) && lastTag.HasPreReleaseTagWithLabel) + if (lastPrefixedSemver != null && MajorMinorPatchEqual(lastPrefixedSemver, semanticVersion) && lastPrefixedSemver.HasPreReleaseTagWithLabel) { - number = lastTag.PreReleaseTag?.Number + 1; + number = lastPrefixedSemver.PreReleaseTag!.Number + 1; } else { number = 1; } - semanticVersion.PreReleaseTag = new SemanticVersionPreReleaseTag(tagToUse, number); + semanticVersion.PreReleaseTag = new SemanticVersionPreReleaseTag(preReleaseTagName, number); } private static bool MajorMinorPatchEqual(SemanticVersion lastTag, SemanticVersion baseVersion) => From 26d9ac3b69ab8e6604d349a934b04ebf811d152a Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Mon, 24 Oct 2022 21:25:35 +0200 Subject: [PATCH 04/11] Reuse existing logic in the MajorMinorPatchEqual method --- .../VersionCalculation/NextVersionCalculator.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs index 2db32de5a2..059f368272 100644 --- a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs @@ -145,8 +145,7 @@ private void UpdatePreReleaseTag(EffectiveBranchConfiguration configuration, Sem semanticVersion.PreReleaseTag = new SemanticVersionPreReleaseTag(preReleaseTagName, number); } - private static bool MajorMinorPatchEqual(SemanticVersion lastTag, SemanticVersion baseVersion) => - lastTag.Major == baseVersion.Major && lastTag.Minor == baseVersion.Minor && lastTag.Patch == baseVersion.Patch; + private static bool MajorMinorPatchEqual(SemanticVersion version, SemanticVersion other) => version.CompareTo(other, false) == 0; private NextVersion Calculate(IBranch branch, GitVersionConfiguration configuration) { From 3442d5a5f12a03884617d018fed4ddd7a37c2f4d Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Mon, 24 Oct 2022 21:27:39 +0200 Subject: [PATCH 05/11] Search for the first prefixed semver only if it matches Major, Minor and Patch --- .../VersionCalculation/NextVersionCalculator.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs index 059f368272..ed2fd7eb35 100644 --- a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs @@ -129,11 +129,12 @@ private void UpdatePreReleaseTag(EffectiveBranchConfiguration configuration, Sem // TODO: Please update the pre release-tag in the IVersionStrategy implementation. var lastPrefixedSemver = this.repositoryStore .GetVersionTagsOnBranch(Context.CurrentBranch, Context.Configuration.LabelPrefix) + .Where(v => MajorMinorPatchEqual(v, semanticVersion) && v.HasPreReleaseTagWithLabel) .FirstOrDefault(v => v.PreReleaseTag?.Name?.IsEquivalentTo(preReleaseTagName) == true); long? number = null; - if (lastPrefixedSemver != null && MajorMinorPatchEqual(lastPrefixedSemver, semanticVersion) && lastPrefixedSemver.HasPreReleaseTagWithLabel) + if (lastPrefixedSemver != null) { number = lastPrefixedSemver.PreReleaseTag!.Number + 1; } From 4828d783168c447fa301fb10332313bd2ea6ea9d Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Mon, 24 Oct 2022 21:42:26 +0200 Subject: [PATCH 06/11] Calculate semver BuildMetaData if versioning mode is not mainline Because `this.mainlineVersionCalculator.FindMainlineModeVersion(nextVersion.BaseVersion)` method calculates BuildMetaData on its own. --- .../VersionCalculation/NextVersionCalculator.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs index ed2fd7eb35..627ea545fd 100644 --- a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs @@ -61,7 +61,7 @@ public virtual NextVersion FindVersion() // var nextVersion = Calculate(Context.CurrentBranch, Context.Configuration); - nextVersion.BaseVersion.SemanticVersion.BuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(nextVersion.BaseVersion.BaseVersionSource); + SemanticVersion semver; if (Context.Configuration.VersioningMode == VersioningMode.Mainline) { @@ -69,10 +69,12 @@ public virtual NextVersion FindVersion() } else { + nextVersion.BaseVersion.SemanticVersion.BuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(nextVersion.BaseVersion.BaseVersionSource); + if (taggedSemanticVersion?.BuildMetaData == null || (taggedSemanticVersion.BuildMetaData?.Sha != nextVersion.BaseVersion.SemanticVersion.BuildMetaData.Sha)) { semver = nextVersion.IncrementedVersion; - semver.BuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(nextVersion.BaseVersion.BaseVersionSource); + semver.BuildMetaData = nextVersion.BaseVersion.SemanticVersion.BuildMetaData; } else { From 15efee0124df46baaac1873e5937d936f08e2b91 Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Mon, 24 Oct 2022 21:49:02 +0200 Subject: [PATCH 07/11] Don't use taggedSemanticVersion to decide which version to take --- .../VersionCalculation/NextVersionCalculator.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs index 627ea545fd..b34c2ccd21 100644 --- a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs @@ -69,17 +69,18 @@ public virtual NextVersion FindVersion() } else { - nextVersion.BaseVersion.SemanticVersion.BuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(nextVersion.BaseVersion.BaseVersionSource); + var baseVersionBuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(nextVersion.BaseVersion.BaseVersionSource); - if (taggedSemanticVersion?.BuildMetaData == null || (taggedSemanticVersion.BuildMetaData?.Sha != nextVersion.BaseVersion.SemanticVersion.BuildMetaData.Sha)) + if (baseVersionBuildMetaData == null || baseVersionBuildMetaData.Sha != nextVersion.IncrementedVersion.BuildMetaData?.Sha) { semver = nextVersion.IncrementedVersion; - semver.BuildMetaData = nextVersion.BaseVersion.SemanticVersion.BuildMetaData; } else { semver = nextVersion.BaseVersion.SemanticVersion; } + + semver.BuildMetaData = baseVersionBuildMetaData; } var hasPreReleaseTag = semver.HasPreReleaseTagWithLabel; From fb0be83093395dc54a6544342ddc2a0983b65fb1 Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Mon, 24 Oct 2022 21:29:28 +0200 Subject: [PATCH 08/11] Get rid of taggedSemanticVersion approach Change next version calculator to act according to the next algorithm: 1. Calculate next version candidate based on the base one 2. Look for the latest `PreReleaseTag` matching Major, Minor and Patch of the next version candidate. 3. Append the `PreReleaseTag`, if found, to the next version candidate. 4. Compare the next version candidate with `Context.CurrentCommitTaggedVersion` including the `PreReleaseTag` comparison. 5. Increment the `PreReleaseTag` of the next version candidate if versions mismatch. 6. Return the next version candidate. --- .../NextVersionCalculator.cs | 93 +++++-------------- 1 file changed, 25 insertions(+), 68 deletions(-) diff --git a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs index b34c2ccd21..63db7f31ca 100644 --- a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs @@ -43,24 +43,8 @@ public virtual NextVersion FindVersion() this.log.Info($"Current commit is tagged with version {Context.CurrentCommitTaggedVersion}, " + "version calculation is for metadata only."); } - // TODO: It is totally unimportant that the current commit has been tagged or not IMO. We can make a double check actually if the result - // is the same or make it configurable but each run should be deterministic.Even if the development process goes on the tagged commit - // should always calculating the same result. Otherwise something is wrong with the configuration or someone messed up the branching history. - - SemanticVersion? taggedSemanticVersion = null; - - if (Context.IsCurrentCommitTagged) - { - // Will always be 0, don't bother with the +0 on tags - var semanticVersionBuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(Context.CurrentCommit); - semanticVersionBuildMetaData.CommitsSinceTag = null; - var semanticVersion = new SemanticVersion(Context.CurrentCommitTaggedVersion) { BuildMetaData = semanticVersionBuildMetaData }; - taggedSemanticVersion = semanticVersion; - } - - // - var nextVersion = Calculate(Context.CurrentBranch, Context.Configuration); + var preReleaseTagName = nextVersion.Configuration.GetBranchSpecificTag(this.log, Context.CurrentBranch.Name.Friendly, nextVersion.BaseVersion.BranchNameOverride); SemanticVersion semver; if (Context.Configuration.VersioningMode == VersioningMode.Mainline) @@ -81,72 +65,45 @@ public virtual NextVersion FindVersion() } semver.BuildMetaData = baseVersionBuildMetaData; + + var lastPrefixedSemver = this.repositoryStore + .GetVersionTagsOnBranch(Context.CurrentBranch, Context.Configuration.LabelPrefix, Context.Configuration.SemanticVersionFormat) + .Where(v => MajorMinorPatchEqual(v, semver) && v.PreReleaseTag?.HasTag() == true) + .FirstOrDefault(v => v.PreReleaseTag?.Name?.IsEquivalentTo(preReleaseTagName) == true); + + if (lastPrefixedSemver != null) + { + semver.PreReleaseTag = lastPrefixedSemver.PreReleaseTag; + } } - var hasPreReleaseTag = semver.HasPreReleaseTagWithLabel; - var tag = nextVersion.Configuration.Label; - var branchConfigHasPreReleaseTagConfigured = !tag.IsNullOrEmpty(); - var branchConfigIsMainlineAndHasEmptyPreReleaseTagConfigured = nextVersion.Configuration.IsMainline && tag.IsEmpty(); - var preReleaseTagDoesNotMatchConfiguration = hasPreReleaseTag - && (branchConfigHasPreReleaseTagConfigured || branchConfigIsMainlineAndHasEmptyPreReleaseTagConfigured) - && semver.PreReleaseTag?.Name != tag; - var preReleaseTagOnlyInBranchConfig = !hasPreReleaseTag && branchConfigHasPreReleaseTagConfigured; - if (preReleaseTagOnlyInBranchConfig || preReleaseTagDoesNotMatchConfiguration) + if (semver.CompareTo(Context.CurrentCommitTaggedVersion) == 0) { - UpdatePreReleaseTag(new(nextVersion.Branch, nextVersion.Configuration), semver, nextVersion.BaseVersion.BranchNameOverride); + // Will always be 0, don't bother with the +0 on tags + semver.BuildMetaData.CommitsSinceTag = null; } - - if (taggedSemanticVersion != null) + else { - // replace calculated version with tagged version only if tagged version greater or equal to calculated version - if (semver.CompareTo(taggedSemanticVersion, false) > 0) + long? number; + + if (semver.PreReleaseTag?.Name == preReleaseTagName) { - taggedSemanticVersion = null; + number = semver.PreReleaseTag.Number + 1; } - else if (taggedSemanticVersion.BuildMetaData != null) + else { - // set the commit count on the tagged ver - taggedSemanticVersion.BuildMetaData.CommitsSinceVersionSource = semver.BuildMetaData?.CommitsSinceVersionSource; - - // set the updated prerelease tag when it doesn't match with prerelease tag defined in branch configuration - if (preReleaseTagDoesNotMatchConfiguration) - { - taggedSemanticVersion.PreReleaseTag = semver.PreReleaseTag; - } + number = 1; } - } - - return new(taggedSemanticVersion ?? semver, nextVersion.BaseVersion, new(nextVersion.Branch, nextVersion.Configuration)); - } - private void UpdatePreReleaseTag(EffectiveBranchConfiguration configuration, SemanticVersion semanticVersion, string? branchNameOverride) - { - var preReleaseTagName = configuration.Value.GetBranchSpecificTag(this.log, Context.CurrentBranch.Name.Friendly, branchNameOverride); - - if (configuration.Value.IsMainline && preReleaseTagName.IsEmpty()) - { - semanticVersion.PreReleaseTag = new SemanticVersionPreReleaseTag(preReleaseTagName, null); - return; + semver.PreReleaseTag = new SemanticVersionPreReleaseTag(preReleaseTagName, number); } - // TODO: Please update the pre release-tag in the IVersionStrategy implementation. - var lastPrefixedSemver = this.repositoryStore - .GetVersionTagsOnBranch(Context.CurrentBranch, Context.Configuration.LabelPrefix) - .Where(v => MajorMinorPatchEqual(v, semanticVersion) && v.HasPreReleaseTagWithLabel) - .FirstOrDefault(v => v.PreReleaseTag?.Name?.IsEquivalentTo(preReleaseTagName) == true); - - long? number = null; - - if (lastPrefixedSemver != null) - { - number = lastPrefixedSemver.PreReleaseTag!.Number + 1; - } - else + if (string.IsNullOrEmpty(preReleaseTagName)) { - number = 1; + semver.PreReleaseTag = new SemanticVersionPreReleaseTag(); } - semanticVersion.PreReleaseTag = new SemanticVersionPreReleaseTag(preReleaseTagName, number); + return new(semver, nextVersion.BaseVersion, new(nextVersion.Branch, nextVersion.Configuration)); } private static bool MajorMinorPatchEqual(SemanticVersion version, SemanticVersion other) => version.CompareTo(other, false) == 0; From 471d1e07c7ba9afdb7a7f371ab50b140e6a45445 Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Sat, 29 Oct 2022 22:55:59 +0200 Subject: [PATCH 09/11] Introduce a `baseVersion` variable to shorten the property call --- .../VersionCalculation/NextVersionCalculator.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs index 63db7f31ca..74d08a3fae 100644 --- a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs @@ -44,16 +44,17 @@ public virtual NextVersion FindVersion() } var nextVersion = Calculate(Context.CurrentBranch, Context.Configuration); - var preReleaseTagName = nextVersion.Configuration.GetBranchSpecificTag(this.log, Context.CurrentBranch.Name.Friendly, nextVersion.BaseVersion.BranchNameOverride); + var baseVersion = nextVersion.BaseVersion; + var preReleaseTagName = nextVersion.Configuration.GetBranchSpecificTag(this.log, Context.CurrentBranch.Name.Friendly, baseVersion.BranchNameOverride); SemanticVersion semver; if (Context.Configuration.VersioningMode == VersioningMode.Mainline) { - semver = this.mainlineVersionCalculator.FindMainlineModeVersion(nextVersion.BaseVersion); + semver = this.mainlineVersionCalculator.FindMainlineModeVersion(baseVersion); } else { - var baseVersionBuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(nextVersion.BaseVersion.BaseVersionSource); + var baseVersionBuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(baseVersion.BaseVersionSource); if (baseVersionBuildMetaData == null || baseVersionBuildMetaData.Sha != nextVersion.IncrementedVersion.BuildMetaData?.Sha) { @@ -61,7 +62,7 @@ public virtual NextVersion FindVersion() } else { - semver = nextVersion.BaseVersion.SemanticVersion; + semver = baseVersion.SemanticVersion; } semver.BuildMetaData = baseVersionBuildMetaData; @@ -103,7 +104,7 @@ public virtual NextVersion FindVersion() semver.PreReleaseTag = new SemanticVersionPreReleaseTag(); } - return new(semver, nextVersion.BaseVersion, new(nextVersion.Branch, nextVersion.Configuration)); + return new(semver, baseVersion, new(nextVersion.Branch, nextVersion.Configuration)); } private static bool MajorMinorPatchEqual(SemanticVersion version, SemanticVersion other) => version.CompareTo(other, false) == 0; From e1bd3a931447c6632bf0d84163c4ff8213520d13 Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Wed, 30 Nov 2022 18:56:40 +0100 Subject: [PATCH 10/11] Remove baseVersionBuildMetaData == null check --- .../NextVersionCalculatorTests.cs | 20 ++++++++++++++----- .../NextVersionCalculator.cs | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/GitVersion.Core.Tests/VersionCalculation/NextVersionCalculatorTests.cs b/src/GitVersion.Core.Tests/VersionCalculation/NextVersionCalculatorTests.cs index 1e95b3517f..0492703e0e 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/NextVersionCalculatorTests.cs +++ b/src/GitVersion.Core.Tests/VersionCalculation/NextVersionCalculatorTests.cs @@ -309,7 +309,9 @@ public void ChoosesHighestVersionReturnedFromStrategies() repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any>()).Returns(Enumerable.Empty()); var dateTimeOffset = DateTimeOffset.Now; var versionStrategies = new IVersionStrategy[] { new V1Strategy(DateTimeOffset.Now), new V2Strategy(dateTimeOffset) }; - var unitUnderTest = new NextVersionCalculator(Substitute.For(), Substitute.For(), + var mainlineVersionCalculatorMock = Substitute.For(); + mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any()).Returns(new SemanticVersionBuildMetaData()); + var unitUnderTest = new NextVersionCalculator(Substitute.For(), mainlineVersionCalculatorMock, repositoryStoreMock, new(context), versionStrategies, effectiveBranchConfigurationFinderMock, incrementStrategyFinderMock); // Act @@ -338,7 +340,9 @@ public void UsesWhenFromNextBestMatchIfHighestDoesntHaveWhen() repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any>()).Returns(Enumerable.Empty()); var when = DateTimeOffset.Now; var versionStrategies = new IVersionStrategy[] { new V1Strategy(when), new V2Strategy(null) }; - var unitUnderTest = new NextVersionCalculator(Substitute.For(), Substitute.For(), + var mainlineVersionCalculatorMock = Substitute.For(); + mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any()).Returns(new SemanticVersionBuildMetaData()); + var unitUnderTest = new NextVersionCalculator(Substitute.For(), mainlineVersionCalculatorMock, repositoryStoreMock, new(context), versionStrategies, effectiveBranchConfigurationFinderMock, incrementStrategyFinderMock); // Act @@ -367,7 +371,9 @@ public void UsesWhenFromNextBestMatchIfHighestDoesntHaveWhenReversedOrder() repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any>()).Returns(Enumerable.Empty()); var when = DateTimeOffset.Now; var versionStrategies = new IVersionStrategy[] { new V2Strategy(null), new V1Strategy(when) }; - var unitUnderTest = new NextVersionCalculator(Substitute.For(), Substitute.For(), + var mainlineVersionCalculatorMock = Substitute.For(); + mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any()).Returns(new SemanticVersionBuildMetaData()); + var unitUnderTest = new NextVersionCalculator(Substitute.For(), mainlineVersionCalculatorMock, repositoryStoreMock, new(context), versionStrategies, effectiveBranchConfigurationFinderMock, incrementStrategyFinderMock); // Act @@ -397,7 +403,9 @@ public void ShouldNotFilterVersion() repositoryStoreMock.GetSourceBranches(branchMock, configuration, Arg.Any>()).Returns(Enumerable.Empty()); var version = new BaseVersion("dummy", false, new SemanticVersion(2), GitToolsTestingExtensions.CreateMockCommit(), null); var versionStrategies = new IVersionStrategy[] { new TestVersionStrategy(version) }; - var unitUnderTest = new NextVersionCalculator(Substitute.For(), Substitute.For(), + var mainlineVersionCalculatorMock = Substitute.For(); + mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any()).Returns(new SemanticVersionBuildMetaData()); + var unitUnderTest = new NextVersionCalculator(Substitute.For(), mainlineVersionCalculatorMock, repositoryStoreMock, new(context), versionStrategies, effectiveBranchConfigurationFinderMock, incrementStrategyFinderMock); // Act @@ -427,7 +435,9 @@ public void ShouldFilterVersion() var higherVersion = new BaseVersion("exclude", false, new SemanticVersion(2), GitToolsTestingExtensions.CreateMockCommit(), null); var lowerVersion = new BaseVersion("dummy", false, new SemanticVersion(1), GitToolsTestingExtensions.CreateMockCommit(), null); var versionStrategies = new IVersionStrategy[] { new TestVersionStrategy(higherVersion, lowerVersion) }; - var unitUnderTest = new NextVersionCalculator(Substitute.For(), Substitute.For(), + var mainlineVersionCalculatorMock = Substitute.For(); + mainlineVersionCalculatorMock.CreateVersionBuildMetaData(Arg.Any()).Returns(new SemanticVersionBuildMetaData()); + var unitUnderTest = new NextVersionCalculator(Substitute.For(), mainlineVersionCalculatorMock, repositoryStoreMock, new(context), versionStrategies, effectiveBranchConfigurationFinderMock, incrementStrategyFinderMock); // Act diff --git a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs index 74d08a3fae..a6b8ebf9a5 100644 --- a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs @@ -56,7 +56,7 @@ public virtual NextVersion FindVersion() { var baseVersionBuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(baseVersion.BaseVersionSource); - if (baseVersionBuildMetaData == null || baseVersionBuildMetaData.Sha != nextVersion.IncrementedVersion.BuildMetaData?.Sha) + if (baseVersionBuildMetaData.Sha != nextVersion.IncrementedVersion.BuildMetaData?.Sha) { semver = nextVersion.IncrementedVersion; } From 5767382777fdfa7e382cf7a49919d632d440b36b Mon Sep 17 00:00:00 2001 From: Alexander Pykavy Date: Fri, 6 Jan 2023 16:31:20 +0100 Subject: [PATCH 11/11] Change SemanticVersion's PreReleaseTag and BuildMetaData to a non-nullable type Because they are always set in SemanticVersion's constructor. They can be null only if explicitly set by the client of the class and there are plans to forbid this functionality. --- .../SemanticVersionTests.cs | 2 - .../VersionCalculation/VersionSourceTests.cs | 3 - .../AssemblyVersionsGeneratorExtensions.cs | 4 +- src/GitVersion.Core/PublicAPI.Shipped.txt | 216 +++++++++--------- .../MainlineVersionCalculator.cs | 2 +- .../NextVersionCalculator.cs | 10 +- .../SemanticVersioning/SemanticVersion.cs | 20 +- .../SemanticVersionFormatValues.cs | 28 +-- .../VersionCalculation/VariableProvider.cs | 41 ++-- 9 files changed, 159 insertions(+), 167 deletions(-) diff --git a/src/GitVersion.Core.Tests/VersionCalculation/SemanticVersionTests.cs b/src/GitVersion.Core.Tests/VersionCalculation/SemanticVersionTests.cs index f36dbe2dad..ee7fd3fd16 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/SemanticVersionTests.cs +++ b/src/GitVersion.Core.Tests/VersionCalculation/SemanticVersionTests.cs @@ -49,11 +49,9 @@ public void ValidateVersionParsing( Assert.AreEqual(major, version.Major); Assert.AreEqual(minor, version.Minor); Assert.AreEqual(patch, version.Patch); - version.PreReleaseTag.ShouldNotBeNull(); Assert.AreEqual(tag, version.PreReleaseTag.Name); Assert.AreEqual(tagNumber, version.PreReleaseTag.Number); - version.BuildMetaData.ShouldNotBeNull(); Assert.AreEqual(numberOfBuilds, version.BuildMetaData.CommitsSinceTag); Assert.AreEqual(branchName, version.BuildMetaData.Branch); Assert.AreEqual(sha, version.BuildMetaData.Sha); diff --git a/src/GitVersion.Core.Tests/VersionCalculation/VersionSourceTests.cs b/src/GitVersion.Core.Tests/VersionCalculation/VersionSourceTests.cs index 9c92ffa78a..9dd1f41fc6 100644 --- a/src/GitVersion.Core.Tests/VersionCalculation/VersionSourceTests.cs +++ b/src/GitVersion.Core.Tests/VersionCalculation/VersionSourceTests.cs @@ -23,7 +23,6 @@ public void VersionSourceSha() var nextVersion = nextVersionCalculator.FindVersion(); - nextVersion.IncrementedVersion.BuildMetaData.ShouldNotBeNull(); nextVersion.IncrementedVersion.BuildMetaData.VersionSourceSha.ShouldBeNull(); nextVersion.IncrementedVersion.BuildMetaData.CommitsSinceVersionSource.ShouldBe(3); } @@ -38,7 +37,6 @@ public void VersionSourceShaOneCommit() var nextVersion = nextVersionCalculator.FindVersion(); - nextVersion.IncrementedVersion.BuildMetaData.ShouldNotBeNull(); nextVersion.IncrementedVersion.BuildMetaData.VersionSourceSha.ShouldBeNull(); nextVersion.IncrementedVersion.BuildMetaData.CommitsSinceVersionSource.ShouldBe(1); } @@ -59,7 +57,6 @@ public void VersionSourceShaUsingTag() var nextVersion = nextVersionCalculator.FindVersion(); - nextVersion.IncrementedVersion.BuildMetaData.ShouldNotBeNull(); nextVersion.IncrementedVersion.BuildMetaData.VersionSourceSha.ShouldBe(secondCommit.Sha); nextVersion.IncrementedVersion.BuildMetaData.CommitsSinceVersionSource.ShouldBe(1); } diff --git a/src/GitVersion.Core/Extensions/AssemblyVersionsGeneratorExtensions.cs b/src/GitVersion.Core/Extensions/AssemblyVersionsGeneratorExtensions.cs index 8f9a7486ae..1ef7f96637 100644 --- a/src/GitVersion.Core/Extensions/AssemblyVersionsGeneratorExtensions.cs +++ b/src/GitVersion.Core/Extensions/AssemblyVersionsGeneratorExtensions.cs @@ -8,7 +8,7 @@ public static class AssemblyVersionsGeneratorExtensions AssemblyVersioningScheme.Major => $"{sv.Major}.0.0.0", AssemblyVersioningScheme.MajorMinor => $"{sv.Major}.{sv.Minor}.0.0", AssemblyVersioningScheme.MajorMinorPatch => $"{sv.Major}.{sv.Minor}.{sv.Patch}.0", - AssemblyVersioningScheme.MajorMinorPatchTag => $"{sv.Major}.{sv.Minor}.{sv.Patch}.{sv.PreReleaseTag?.Number ?? 0}", + AssemblyVersioningScheme.MajorMinorPatchTag => $"{sv.Major}.{sv.Minor}.{sv.Patch}.{sv.PreReleaseTag.Number ?? 0}", AssemblyVersioningScheme.None => null, _ => throw new ArgumentException($"Unexpected value ({scheme}).", nameof(scheme)) }; @@ -19,7 +19,7 @@ public static class AssemblyVersionsGeneratorExtensions AssemblyFileVersioningScheme.Major => $"{sv.Major}.0.0.0", AssemblyFileVersioningScheme.MajorMinor => $"{sv.Major}.{sv.Minor}.0.0", AssemblyFileVersioningScheme.MajorMinorPatch => $"{sv.Major}.{sv.Minor}.{sv.Patch}.0", - AssemblyFileVersioningScheme.MajorMinorPatchTag => $"{sv.Major}.{sv.Minor}.{sv.Patch}.{sv.PreReleaseTag?.Number ?? 0}", + AssemblyFileVersioningScheme.MajorMinorPatchTag => $"{sv.Major}.{sv.Minor}.{sv.Patch}.{sv.PreReleaseTag.Number ?? 0}", AssemblyFileVersioningScheme.None => null, _ => throw new ArgumentException($"Unexpected value ({scheme}).", nameof(scheme)) }; diff --git a/src/GitVersion.Core/PublicAPI.Shipped.txt b/src/GitVersion.Core/PublicAPI.Shipped.txt index a294c5b62e..c236b0a15d 100644 --- a/src/GitVersion.Core/PublicAPI.Shipped.txt +++ b/src/GitVersion.Core/PublicAPI.Shipped.txt @@ -1,55 +1,4 @@ #nullable enable -abstract GitVersion.BuildAgents.BuildAgentBase.EnvironmentVariable.get -> string! -abstract GitVersion.BuildAgents.BuildAgentBase.GenerateSetParameterMessage(string! name, string! value) -> string![]! -abstract GitVersion.BuildAgents.BuildAgentBase.GenerateSetVersionMessage(GitVersion.OutputVariables.VersionVariables! variables) -> string? -abstract GitVersion.Configuration.Init.Wizard.ConfigInitWizardStep.DefaultResult.get -> string? -abstract GitVersion.Configuration.Init.Wizard.ConfigInitWizardStep.GetPrompt(GitVersion.Configuration.GitVersionConfiguration! configuration, string! workingDirectory) -> string! -abstract GitVersion.Configuration.Init.Wizard.ConfigInitWizardStep.HandleResult(string? result, System.Collections.Generic.Queue! steps, GitVersion.Configuration.GitVersionConfiguration! configuration, string! workingDirectory) -> GitVersion.Configuration.Init.StepResult! -abstract GitVersion.GitVersionModule.RegisterTypes(Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> void -abstract GitVersion.VersionCalculation.VersionStrategyBase.GetBaseVersions(GitVersion.Configuration.EffectiveBranchConfiguration! configuration) -> System.Collections.Generic.IEnumerable! -const GitVersion.BuildAgents.AppVeyor.EnvironmentVariableName = "APPVEYOR" -> string! -const GitVersion.BuildAgents.AzurePipelines.EnvironmentVariableName = "TF_BUILD" -> string! -const GitVersion.BuildAgents.BitBucketPipelines.BranchEnvironmentVariableName = "BITBUCKET_BRANCH" -> string! -const GitVersion.BuildAgents.BitBucketPipelines.EnvironmentVariableName = "BITBUCKET_WORKSPACE" -> string! -const GitVersion.BuildAgents.BitBucketPipelines.PullRequestEnvironmentVariableName = "BITBUCKET_PR_ID" -> string! -const GitVersion.BuildAgents.BitBucketPipelines.TagEnvironmentVariableName = "BITBUCKET_TAG" -> string! -const GitVersion.BuildAgents.BuildKite.EnvironmentVariableName = "BUILDKITE" -> string! -const GitVersion.BuildAgents.CodeBuild.SourceVersionEnvironmentVariableName = "CODEBUILD_SOURCE_VERSION" -> string! -const GitVersion.BuildAgents.CodeBuild.WebHookEnvironmentVariableName = "CODEBUILD_WEBHOOK_HEAD_REF" -> string! -const GitVersion.BuildAgents.ContinuaCi.EnvironmentVariableName = "ContinuaCI.Version" -> string! -const GitVersion.BuildAgents.Drone.EnvironmentVariableName = "DRONE" -> string! -const GitVersion.BuildAgents.EnvRun.EnvironmentVariableName = "ENVRUN_DATABASE" -> string! -const GitVersion.BuildAgents.GitHubActions.EnvironmentVariableName = "GITHUB_ACTIONS" -> string! -const GitVersion.BuildAgents.GitHubActions.GitHubSetEnvTempFileEnvironmentVariableName = "GITHUB_ENV" -> string! -const GitVersion.BuildAgents.GitLabCi.EnvironmentVariableName = "GITLAB_CI" -> string! -const GitVersion.BuildAgents.Jenkins.EnvironmentVariableName = "JENKINS_URL" -> string! -const GitVersion.BuildAgents.MyGet.EnvironmentVariableName = "BuildRunner" -> string! -const GitVersion.BuildAgents.SpaceAutomation.EnvironmentVariableName = "JB_SPACE_PROJECT_KEY" -> string! -const GitVersion.BuildAgents.TeamCity.EnvironmentVariableName = "TEAMCITY_VERSION" -> string! -const GitVersion.BuildAgents.TravisCi.EnvironmentVariableName = "TRAVIS" -> string! -const GitVersion.Configuration.ConfigurationFileLocator.DefaultFileName = "GitVersion.yml" -> string! -const GitVersion.Configuration.GitVersionConfiguration.DefaultLabelPrefix = "[vV]?" -> string! -const GitVersion.Configuration.GitVersionConfiguration.DevelopBranchKey = "develop" -> string! -const GitVersion.Configuration.GitVersionConfiguration.DevelopBranchRegex = "^dev(elop)?(ment)?$" -> string! -const GitVersion.Configuration.GitVersionConfiguration.FeatureBranchKey = "feature" -> string! -const GitVersion.Configuration.GitVersionConfiguration.FeatureBranchRegex = "^features?[/-]" -> string! -const GitVersion.Configuration.GitVersionConfiguration.HotfixBranchKey = "hotfix" -> string! -const GitVersion.Configuration.GitVersionConfiguration.HotfixBranchRegex = "^hotfix(es)?[/-]" -> string! -const GitVersion.Configuration.GitVersionConfiguration.MainBranchKey = "main" -> string! -const GitVersion.Configuration.GitVersionConfiguration.MainBranchRegex = "^master$|^main$" -> string! -const GitVersion.Configuration.GitVersionConfiguration.MasterBranchKey = "master" -> string! -const GitVersion.Configuration.GitVersionConfiguration.PullRequestBranchKey = "pull-request" -> string! -const GitVersion.Configuration.GitVersionConfiguration.PullRequestRegex = "^(pull|pull\\-requests|pr)[/-]" -> string! -const GitVersion.Configuration.GitVersionConfiguration.ReleaseBranchKey = "release" -> string! -const GitVersion.Configuration.GitVersionConfiguration.ReleaseBranchRegex = "^releases?[/-]" -> string! -const GitVersion.Configuration.GitVersionConfiguration.SupportBranchKey = "support" -> string! -const GitVersion.Configuration.GitVersionConfiguration.SupportBranchRegex = "^support[/-]" -> string! -const GitVersion.VersionCalculation.IncrementStrategyFinder.DefaultMajorPattern = "\\+semver:\\s?(breaking|major)" -> string! -const GitVersion.VersionCalculation.IncrementStrategyFinder.DefaultMinorPattern = "\\+semver:\\s?(feature|minor)" -> string! -const GitVersion.VersionCalculation.IncrementStrategyFinder.DefaultNoBumpPattern = "\\+semver:\\s?(none|skip)" -> string! -const GitVersion.VersionCalculation.IncrementStrategyFinder.DefaultPatchPattern = "\\+semver:\\s?(fix|patch)" -> string! -const GitVersion.VersionCalculation.MergeMessageVersionStrategy.MergeMessageStrategyPrefix = "Merge message" -> string! -const GitVersion.VersionConverters.WixUpdater.WixVersionFileUpdater.WixVersionFileName = "GitVersion_WixVersion.wxi" -> string! GitVersion.AssemblyInfoData GitVersion.AssemblyInfoData.AssemblyInfoData() -> void GitVersion.AssemblyInfoData.EnsureAssemblyInfo -> bool @@ -144,9 +93,9 @@ GitVersion.CommitSortStrategies.Topological = 1 -> GitVersion.CommitSortStrategi GitVersion.Common.IRepositoryStore GitVersion.Common.IRepositoryStore.ExcludingBranches(System.Collections.Generic.IEnumerable! branchesToExclude) -> System.Collections.Generic.IEnumerable! GitVersion.Common.IRepositoryStore.FindBranch(string? branchName) -> GitVersion.IBranch? -GitVersion.Common.IRepositoryStore.FindCommitBranchesWasBranchedFrom(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, params GitVersion.IBranch![]! excludedBranches) -> System.Collections.Generic.IEnumerable! -GitVersion.Common.IRepositoryStore.FindCommitBranchesWasBranchedFrom(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, System.Collections.Generic.IEnumerable! excludedBranches) -> System.Collections.Generic.IEnumerable! GitVersion.Common.IRepositoryStore.FindCommitBranchWasBranchedFrom(GitVersion.IBranch? branch, GitVersion.Configuration.GitVersionConfiguration! configuration, params GitVersion.IBranch![]! excludedBranches) -> GitVersion.BranchCommit +GitVersion.Common.IRepositoryStore.FindCommitBranchesWasBranchedFrom(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, System.Collections.Generic.IEnumerable! excludedBranches) -> System.Collections.Generic.IEnumerable! +GitVersion.Common.IRepositoryStore.FindCommitBranchesWasBranchedFrom(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, params GitVersion.IBranch![]! excludedBranches) -> System.Collections.Generic.IEnumerable! GitVersion.Common.IRepositoryStore.FindMainBranch(GitVersion.Configuration.GitVersionConfiguration! configuration) -> GitVersion.IBranch? GitVersion.Common.IRepositoryStore.FindMergeBase(GitVersion.IBranch? branch, GitVersion.IBranch? otherBranch) -> GitVersion.ICommit? GitVersion.Common.IRepositoryStore.FindMergeBase(GitVersion.ICommit! commit, GitVersion.ICommit! mainlineTip) -> GitVersion.ICommit? @@ -159,8 +108,8 @@ GitVersion.Common.IRepositoryStore.GetMainlineCommitLog(GitVersion.ICommit? base GitVersion.Common.IRepositoryStore.GetMergeBaseCommits(GitVersion.ICommit? mergeCommit, GitVersion.ICommit? mergedHead, GitVersion.ICommit? findMergeBase) -> System.Collections.Generic.IEnumerable! GitVersion.Common.IRepositoryStore.GetNumberOfUncommittedChanges() -> int GitVersion.Common.IRepositoryStore.GetReleaseBranches(System.Collections.Generic.IEnumerable>! releaseBranchConfig) -> System.Collections.Generic.IEnumerable! -GitVersion.Common.IRepositoryStore.GetSourceBranches(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, params GitVersion.IBranch![]! excludedBranches) -> System.Collections.Generic.IEnumerable! GitVersion.Common.IRepositoryStore.GetSourceBranches(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, System.Collections.Generic.IEnumerable! excludedBranches) -> System.Collections.Generic.IEnumerable! +GitVersion.Common.IRepositoryStore.GetSourceBranches(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, params GitVersion.IBranch![]! excludedBranches) -> System.Collections.Generic.IEnumerable! GitVersion.Common.IRepositoryStore.GetTargetBranch(string? targetBranchName) -> GitVersion.IBranch! GitVersion.Common.IRepositoryStore.GetValidVersionTags(string? tagPrefixRegex, GitVersion.SemanticVersionFormat versionFormat, System.DateTimeOffset? olderThan = null) -> System.Collections.Generic.IEnumerable<(GitVersion.ITag! Tag, GitVersion.SemanticVersion! Semver, GitVersion.ICommit! Commit)>! GitVersion.Common.IRepositoryStore.GetVersionTagsOnBranch(GitVersion.IBranch! branch, string? tagPrefixRegex, GitVersion.SemanticVersionFormat versionFormat) -> System.Collections.Generic.IEnumerable! @@ -185,6 +134,10 @@ GitVersion.Configuration.BranchConfiguration.IsReleaseBranch.get -> bool? GitVersion.Configuration.BranchConfiguration.IsReleaseBranch.set -> void GitVersion.Configuration.BranchConfiguration.IsSourceBranchFor.get -> System.Collections.Generic.HashSet? GitVersion.Configuration.BranchConfiguration.IsSourceBranchFor.set -> void +GitVersion.Configuration.BranchConfiguration.Label.get -> string? +GitVersion.Configuration.BranchConfiguration.Label.set -> void +GitVersion.Configuration.BranchConfiguration.LabelNumberPattern.get -> string? +GitVersion.Configuration.BranchConfiguration.LabelNumberPattern.set -> void GitVersion.Configuration.BranchConfiguration.MergeTo(GitVersion.Configuration.BranchConfiguration! targetConfig) -> void GitVersion.Configuration.BranchConfiguration.Name.get -> string! GitVersion.Configuration.BranchConfiguration.Name.set -> void @@ -196,10 +149,6 @@ GitVersion.Configuration.BranchConfiguration.Regex.get -> string? GitVersion.Configuration.BranchConfiguration.Regex.set -> void GitVersion.Configuration.BranchConfiguration.SourceBranches.get -> System.Collections.Generic.HashSet? GitVersion.Configuration.BranchConfiguration.SourceBranches.set -> void -GitVersion.Configuration.BranchConfiguration.Label.get -> string? -GitVersion.Configuration.BranchConfiguration.Label.set -> void -GitVersion.Configuration.BranchConfiguration.LabelNumberPattern.get -> string? -GitVersion.Configuration.BranchConfiguration.LabelNumberPattern.set -> void GitVersion.Configuration.BranchConfiguration.TrackMergeTarget.get -> bool? GitVersion.Configuration.BranchConfiguration.TrackMergeTarget.set -> void GitVersion.Configuration.BranchConfiguration.TracksReleaseBranches.get -> bool? @@ -252,6 +201,10 @@ GitVersion.Configuration.EffectiveConfiguration.EffectiveConfiguration(GitVersio GitVersion.Configuration.EffectiveConfiguration.Increment.get -> GitVersion.IncrementStrategy GitVersion.Configuration.EffectiveConfiguration.IsMainline.get -> bool GitVersion.Configuration.EffectiveConfiguration.IsReleaseBranch.get -> bool +GitVersion.Configuration.EffectiveConfiguration.Label.get -> string! +GitVersion.Configuration.EffectiveConfiguration.LabelNumberPattern.get -> string? +GitVersion.Configuration.EffectiveConfiguration.LabelPreReleaseWeight.get -> int +GitVersion.Configuration.EffectiveConfiguration.LabelPrefix.get -> string? GitVersion.Configuration.EffectiveConfiguration.MajorVersionBumpMessage.get -> string? GitVersion.Configuration.EffectiveConfiguration.MinorVersionBumpMessage.get -> string? GitVersion.Configuration.EffectiveConfiguration.NextVersion.get -> string? @@ -261,10 +214,6 @@ GitVersion.Configuration.EffectiveConfiguration.PreReleaseWeight.get -> int GitVersion.Configuration.EffectiveConfiguration.PreventIncrementOfMergedBranchVersion.get -> bool GitVersion.Configuration.EffectiveConfiguration.SemanticVersionFormat.get -> GitVersion.SemanticVersionFormat GitVersion.Configuration.EffectiveConfiguration.SemanticVersionFormat.set -> void -GitVersion.Configuration.EffectiveConfiguration.Label.get -> string! -GitVersion.Configuration.EffectiveConfiguration.LabelNumberPattern.get -> string? -GitVersion.Configuration.EffectiveConfiguration.LabelPrefix.get -> string? -GitVersion.Configuration.EffectiveConfiguration.LabelPreReleaseWeight.get -> int GitVersion.Configuration.EffectiveConfiguration.TrackMergeTarget.get -> bool GitVersion.Configuration.EffectiveConfiguration.TracksReleaseBranches.get -> bool GitVersion.Configuration.EffectiveConfiguration.UpdateBuildNumber.get -> bool @@ -294,6 +243,10 @@ GitVersion.Configuration.GitVersionConfiguration.Ignore.get -> GitVersion.Config GitVersion.Configuration.GitVersionConfiguration.Ignore.set -> void GitVersion.Configuration.GitVersionConfiguration.Increment.get -> GitVersion.IncrementStrategy? GitVersion.Configuration.GitVersionConfiguration.Increment.set -> void +GitVersion.Configuration.GitVersionConfiguration.LabelPreReleaseWeight.get -> int? +GitVersion.Configuration.GitVersionConfiguration.LabelPreReleaseWeight.set -> void +GitVersion.Configuration.GitVersionConfiguration.LabelPrefix.get -> string? +GitVersion.Configuration.GitVersionConfiguration.LabelPrefix.set -> void GitVersion.Configuration.GitVersionConfiguration.MajorVersionBumpMessage.get -> string? GitVersion.Configuration.GitVersionConfiguration.MajorVersionBumpMessage.set -> void GitVersion.Configuration.GitVersionConfiguration.MergeMessageFormats.get -> System.Collections.Generic.Dictionary! @@ -308,10 +261,6 @@ GitVersion.Configuration.GitVersionConfiguration.PatchVersionBumpMessage.get -> GitVersion.Configuration.GitVersionConfiguration.PatchVersionBumpMessage.set -> void GitVersion.Configuration.GitVersionConfiguration.SemanticVersionFormat.get -> GitVersion.SemanticVersionFormat GitVersion.Configuration.GitVersionConfiguration.SemanticVersionFormat.set -> void -GitVersion.Configuration.GitVersionConfiguration.LabelPrefix.get -> string? -GitVersion.Configuration.GitVersionConfiguration.LabelPrefix.set -> void -GitVersion.Configuration.GitVersionConfiguration.LabelPreReleaseWeight.get -> int? -GitVersion.Configuration.GitVersionConfiguration.LabelPreReleaseWeight.set -> void GitVersion.Configuration.GitVersionConfiguration.UpdateBuildNumber.get -> bool? GitVersion.Configuration.GitVersionConfiguration.UpdateBuildNumber.set -> void GitVersion.Configuration.GitVersionConfiguration.VersioningMode.get -> GitVersion.VersionCalculation.VersioningMode? @@ -515,8 +464,8 @@ GitVersion.IBranch.IsTracking.get -> bool GitVersion.IBranch.Tip.get -> GitVersion.ICommit? GitVersion.IBranchCollection GitVersion.IBranchCollection.ExcludeBranches(System.Collections.Generic.IEnumerable! branchesToExclude) -> System.Collections.Generic.IEnumerable! -GitVersion.IBranchCollection.this[string! name].get -> GitVersion.IBranch? GitVersion.IBranchCollection.UpdateTrackedBranch(GitVersion.IBranch! branch, string! remoteTrackingReferenceName) -> void +GitVersion.IBranchCollection.this[string! name].get -> GitVersion.IBranch? GitVersion.ICommit GitVersion.ICommit.Message.get -> string! GitVersion.ICommit.Parents.get -> System.Collections.Generic.IEnumerable! @@ -583,16 +532,15 @@ GitVersion.IMutatingGitRepository.CreateBranchForPullRequestBranch(GitVersion.Au GitVersion.IMutatingGitRepository.Fetch(string! remote, System.Collections.Generic.IEnumerable! refSpecs, GitVersion.AuthenticationInfo! auth, string? logMessage) -> void GitVersion.INamedReference GitVersion.INamedReference.Name.get -> GitVersion.ReferenceName! -GitVersion.IncrementStrategy -GitVersion.IncrementStrategy.Inherit = 4 -> GitVersion.IncrementStrategy -GitVersion.IncrementStrategy.Major = 1 -> GitVersion.IncrementStrategy -GitVersion.IncrementStrategy.Minor = 2 -> GitVersion.IncrementStrategy -GitVersion.IncrementStrategy.None = 0 -> GitVersion.IncrementStrategy -GitVersion.IncrementStrategy.Patch = 3 -> GitVersion.IncrementStrategy -GitVersion.IncrementStrategyExtensions GitVersion.IObjectId GitVersion.IObjectId.Sha.get -> string! GitVersion.IObjectId.ToString(int prefixLength) -> string! +GitVersion.IRefSpec +GitVersion.IRefSpec.Destination.get -> string! +GitVersion.IRefSpec.Direction.get -> GitVersion.RefSpecDirection +GitVersion.IRefSpec.Source.get -> string! +GitVersion.IRefSpec.Specification.get -> string! +GitVersion.IRefSpecCollection GitVersion.IReference GitVersion.IReference.ReferenceTargetId.get -> GitVersion.IObjectId? GitVersion.IReference.TargetIdentifier.get -> string! @@ -600,15 +548,9 @@ GitVersion.IReferenceCollection GitVersion.IReferenceCollection.Add(string! name, string! canonicalRefNameOrObject, bool allowOverwrite = false) -> void GitVersion.IReferenceCollection.FromGlob(string! prefix) -> System.Collections.Generic.IEnumerable! GitVersion.IReferenceCollection.Head.get -> GitVersion.IReference? +GitVersion.IReferenceCollection.UpdateTarget(GitVersion.IReference! directRef, GitVersion.IObjectId! targetId) -> void GitVersion.IReferenceCollection.this[GitVersion.ReferenceName! referenceName].get -> GitVersion.IReference? GitVersion.IReferenceCollection.this[string! name].get -> GitVersion.IReference? -GitVersion.IReferenceCollection.UpdateTarget(GitVersion.IReference! directRef, GitVersion.IObjectId! targetId) -> void -GitVersion.IRefSpec -GitVersion.IRefSpec.Destination.get -> string! -GitVersion.IRefSpec.Direction.get -> GitVersion.RefSpecDirection -GitVersion.IRefSpec.Source.get -> string! -GitVersion.IRefSpec.Specification.get -> string! -GitVersion.IRefSpecCollection GitVersion.IRemote GitVersion.IRemote.FetchRefSpecs.get -> System.Collections.Generic.IEnumerable! GitVersion.IRemote.Name.get -> string! @@ -617,12 +559,19 @@ GitVersion.IRemote.RefSpecs.get -> System.Collections.Generic.IEnumerable string! GitVersion.IRemoteCollection GitVersion.IRemoteCollection.Remove(string! remoteName) -> void -GitVersion.IRemoteCollection.this[string! name].get -> GitVersion.IRemote? GitVersion.IRemoteCollection.Update(string! remoteName, string! refSpec) -> void +GitVersion.IRemoteCollection.this[string! name].get -> GitVersion.IRemote? GitVersion.ITag GitVersion.ITag.PeeledTargetCommit() -> GitVersion.ICommit? GitVersion.ITag.TargetSha.get -> string? GitVersion.ITagCollection +GitVersion.IncrementStrategy +GitVersion.IncrementStrategy.Inherit = 4 -> GitVersion.IncrementStrategy +GitVersion.IncrementStrategy.Major = 1 -> GitVersion.IncrementStrategy +GitVersion.IncrementStrategy.Minor = 2 -> GitVersion.IncrementStrategy +GitVersion.IncrementStrategy.None = 0 -> GitVersion.IncrementStrategy +GitVersion.IncrementStrategy.Patch = 3 -> GitVersion.IncrementStrategy +GitVersion.IncrementStrategyExtensions GitVersion.LockedFileException GitVersion.LockedFileException.LockedFileException(System.Exception! inner) -> void GitVersion.Logging.ConsoleAdapter @@ -689,8 +638,8 @@ GitVersion.Logging.Verbosity.Verbose = 3 -> GitVersion.Logging.Verbosity GitVersion.MergeMessage GitVersion.MergeMessage.FormatName.get -> string? GitVersion.MergeMessage.IsMergedPullRequest.get -> bool -GitVersion.MergeMessage.MergedBranch.get -> string! GitVersion.MergeMessage.MergeMessage(string? mergeMessage, GitVersion.Configuration.GitVersionConfiguration! configuration) -> void +GitVersion.MergeMessage.MergedBranch.get -> string! GitVersion.MergeMessage.PullRequestNumber.get -> int? GitVersion.MergeMessage.TargetBranch.get -> string? GitVersion.MergeMessage.Version.get -> GitVersion.SemanticVersion? @@ -725,12 +674,12 @@ GitVersion.OutputVariables.VersionVariables.PreReleaseTagWithDash.get -> string? GitVersion.OutputVariables.VersionVariables.SemVer.get -> string! GitVersion.OutputVariables.VersionVariables.Sha.get -> string? GitVersion.OutputVariables.VersionVariables.ShortSha.get -> string? -GitVersion.OutputVariables.VersionVariables.this[string! variable].get -> string? GitVersion.OutputVariables.VersionVariables.TryGetValue(string! variable, out string? variableValue) -> bool GitVersion.OutputVariables.VersionVariables.UncommittedChanges.get -> string? GitVersion.OutputVariables.VersionVariables.VersionSourceSha.get -> string? GitVersion.OutputVariables.VersionVariables.VersionVariables(string! major, string! minor, string! patch, string? buildMetaData, string? fullBuildMetaData, string? branchName, string? escapedBranchName, string? sha, string? shortSha, string! majorMinorPatch, string! semVer, string! fullSemVer, string? assemblySemVer, string? assemblySemFileVer, string? preReleaseTag, string? preReleaseTagWithDash, string? preReleaseLabel, string? preReleaseLabelWithDash, string? preReleaseNumber, string! weightedPreReleaseNumber, string? informationalVersion, string? commitDate, string? versionSourceSha, string? commitsSinceVersionSource, string? uncommittedChanges) -> void GitVersion.OutputVariables.VersionVariables.WeightedPreReleaseNumber.get -> string! +GitVersion.OutputVariables.VersionVariables.this[string! variable].get -> string? GitVersion.OutputVariables.VersionVariablesJsonModel GitVersion.OutputVariables.VersionVariablesJsonModel.AssemblySemFileVer.get -> string? GitVersion.OutputVariables.VersionVariablesJsonModel.AssemblySemFileVer.set -> void @@ -787,6 +736,9 @@ GitVersion.OutputVariables.VersionVariablesJsonNumberConverter GitVersion.OutputVariables.VersionVariablesJsonNumberConverter.VersionVariablesJsonNumberConverter() -> void GitVersion.OutputVariables.VersionVariablesJsonStringConverter GitVersion.OutputVariables.VersionVariablesJsonStringConverter.VersionVariablesJsonStringConverter() -> void +GitVersion.RefSpecDirection +GitVersion.RefSpecDirection.Fetch = 0 -> GitVersion.RefSpecDirection +GitVersion.RefSpecDirection.Push = 1 -> GitVersion.RefSpecDirection GitVersion.ReferenceName GitVersion.ReferenceName.Canonical.get -> string! GitVersion.ReferenceName.CompareTo(GitVersion.ReferenceName? other) -> int @@ -799,9 +751,6 @@ GitVersion.ReferenceName.IsRemoteBranch.get -> bool GitVersion.ReferenceName.IsTag.get -> bool GitVersion.ReferenceName.ReferenceName(string! canonical) -> void GitVersion.ReferenceName.WithoutRemote.get -> string! -GitVersion.RefSpecDirection -GitVersion.RefSpecDirection.Fetch = 0 -> GitVersion.RefSpecDirection -GitVersion.RefSpecDirection.Push = 1 -> GitVersion.RefSpecDirection GitVersion.RepositoryInfo GitVersion.RepositoryInfo.ClonePath -> string? GitVersion.RepositoryInfo.CommitId -> string? @@ -811,9 +760,9 @@ GitVersion.RepositoryInfo.TargetUrl -> string? GitVersion.RepositoryStore GitVersion.RepositoryStore.ExcludingBranches(System.Collections.Generic.IEnumerable! branchesToExclude) -> System.Collections.Generic.IEnumerable! GitVersion.RepositoryStore.FindBranch(string? branchName) -> GitVersion.IBranch? -GitVersion.RepositoryStore.FindCommitBranchesWasBranchedFrom(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, params GitVersion.IBranch![]! excludedBranches) -> System.Collections.Generic.IEnumerable! -GitVersion.RepositoryStore.FindCommitBranchesWasBranchedFrom(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, System.Collections.Generic.IEnumerable! excludedBranches) -> System.Collections.Generic.IEnumerable! GitVersion.RepositoryStore.FindCommitBranchWasBranchedFrom(GitVersion.IBranch? branch, GitVersion.Configuration.GitVersionConfiguration! configuration, params GitVersion.IBranch![]! excludedBranches) -> GitVersion.BranchCommit +GitVersion.RepositoryStore.FindCommitBranchesWasBranchedFrom(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, System.Collections.Generic.IEnumerable! excludedBranches) -> System.Collections.Generic.IEnumerable! +GitVersion.RepositoryStore.FindCommitBranchesWasBranchedFrom(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, params GitVersion.IBranch![]! excludedBranches) -> System.Collections.Generic.IEnumerable! GitVersion.RepositoryStore.FindMainBranch(GitVersion.Configuration.GitVersionConfiguration! configuration) -> GitVersion.IBranch? GitVersion.RepositoryStore.FindMergeBase(GitVersion.IBranch? branch, GitVersion.IBranch? otherBranch) -> GitVersion.ICommit? GitVersion.RepositoryStore.FindMergeBase(GitVersion.ICommit! commit, GitVersion.ICommit! mainlineTip) -> GitVersion.ICommit? @@ -826,15 +775,15 @@ GitVersion.RepositoryStore.GetMainlineCommitLog(GitVersion.ICommit? baseVersionS GitVersion.RepositoryStore.GetMergeBaseCommits(GitVersion.ICommit? mergeCommit, GitVersion.ICommit? mergedHead, GitVersion.ICommit? findMergeBase) -> System.Collections.Generic.IEnumerable! GitVersion.RepositoryStore.GetNumberOfUncommittedChanges() -> int GitVersion.RepositoryStore.GetReleaseBranches(System.Collections.Generic.IEnumerable>! releaseBranchConfig) -> System.Collections.Generic.IEnumerable! -GitVersion.RepositoryStore.GetSourceBranches(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, params GitVersion.IBranch![]! excludedBranches) -> System.Collections.Generic.IEnumerable! GitVersion.RepositoryStore.GetSourceBranches(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, System.Collections.Generic.IEnumerable! excludedBranches) -> System.Collections.Generic.IEnumerable! +GitVersion.RepositoryStore.GetSourceBranches(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration, params GitVersion.IBranch![]! excludedBranches) -> System.Collections.Generic.IEnumerable! GitVersion.RepositoryStore.GetTargetBranch(string? targetBranchName) -> GitVersion.IBranch! GitVersion.RepositoryStore.GetValidVersionTags(string? tagPrefixRegex, GitVersion.SemanticVersionFormat versionFormat, System.DateTimeOffset? olderThan = null) -> System.Collections.Generic.IEnumerable<(GitVersion.ITag! Tag, GitVersion.SemanticVersion! Semver, GitVersion.ICommit! Commit)>! GitVersion.RepositoryStore.GetVersionTagsOnBranch(GitVersion.IBranch! branch, string? tagPrefixRegex, GitVersion.SemanticVersionFormat versionFormat) -> System.Collections.Generic.IEnumerable! GitVersion.RepositoryStore.IsCommitOnBranch(GitVersion.ICommit? baseVersionSource, GitVersion.IBranch! branch, GitVersion.ICommit! firstMatchingCommit) -> bool GitVersion.RepositoryStore.RepositoryStore(GitVersion.Logging.ILog! log, GitVersion.IGitRepository! repository) -> void GitVersion.SemanticVersion -GitVersion.SemanticVersion.BuildMetaData -> GitVersion.SemanticVersionBuildMetaData? +GitVersion.SemanticVersion.BuildMetaData -> GitVersion.SemanticVersionBuildMetaData! GitVersion.SemanticVersion.CompareTo(GitVersion.SemanticVersion? value) -> int GitVersion.SemanticVersion.CompareTo(GitVersion.SemanticVersion? value, bool includePrerelease) -> int GitVersion.SemanticVersion.Equals(GitVersion.SemanticVersion? obj) -> bool @@ -844,7 +793,7 @@ GitVersion.SemanticVersion.IsEmpty() -> bool GitVersion.SemanticVersion.Major -> long GitVersion.SemanticVersion.Minor -> long GitVersion.SemanticVersion.Patch -> long -GitVersion.SemanticVersion.PreReleaseTag -> GitVersion.SemanticVersionPreReleaseTag? +GitVersion.SemanticVersion.PreReleaseTag -> GitVersion.SemanticVersionPreReleaseTag! GitVersion.SemanticVersion.SemanticVersion(GitVersion.SemanticVersion? semanticVersion) -> void GitVersion.SemanticVersion.SemanticVersion(long major = 0, long minor = 0, long patch = 0) -> void GitVersion.SemanticVersion.ToString(string! format) -> string! @@ -888,8 +837,8 @@ GitVersion.SemanticVersionFormatValues.PreReleaseLabelWithDash.get -> string? GitVersion.SemanticVersionFormatValues.PreReleaseNumber.get -> string? GitVersion.SemanticVersionFormatValues.PreReleaseTag.get -> string? GitVersion.SemanticVersionFormatValues.PreReleaseTagWithDash.get -> string? -GitVersion.SemanticVersionFormatValues.SemanticVersionFormatValues(GitVersion.SemanticVersion! semver, GitVersion.Configuration.EffectiveConfiguration! configuration) -> void GitVersion.SemanticVersionFormatValues.SemVer.get -> string! +GitVersion.SemanticVersionFormatValues.SemanticVersionFormatValues(GitVersion.SemanticVersion! semver, GitVersion.Configuration.EffectiveConfiguration! configuration) -> void GitVersion.SemanticVersionFormatValues.Sha.get -> string? GitVersion.SemanticVersionFormatValues.ShortSha.get -> string? GitVersion.SemanticVersionFormatValues.UncommittedChanges.get -> string? @@ -958,10 +907,6 @@ GitVersion.VersionCalculation.IIncrementStrategyFinder.GetIncrementForCommits(Gi GitVersion.VersionCalculation.IMainlineVersionCalculator GitVersion.VersionCalculation.IMainlineVersionCalculator.CreateVersionBuildMetaData(GitVersion.ICommit? baseVersionSource) -> GitVersion.SemanticVersionBuildMetaData! GitVersion.VersionCalculation.IMainlineVersionCalculator.FindMainlineModeVersion(GitVersion.VersionCalculation.BaseVersion! baseVersion) -> GitVersion.SemanticVersion! -GitVersion.VersionCalculation.IncrementStrategyFinder -GitVersion.VersionCalculation.IncrementStrategyFinder.DetermineIncrementedField(GitVersion.GitVersionContext! context, GitVersion.VersionCalculation.BaseVersion! baseVersion, GitVersion.Configuration.EffectiveConfiguration! configuration) -> GitVersion.VersionField -GitVersion.VersionCalculation.IncrementStrategyFinder.GetIncrementForCommits(GitVersion.Configuration.GitVersionConfiguration! configuration, System.Collections.Generic.IEnumerable! commits) -> GitVersion.VersionField? -GitVersion.VersionCalculation.IncrementStrategyFinder.IncrementStrategyFinder(GitVersion.IGitRepository! repository) -> void GitVersion.VersionCalculation.INextVersionCalculator GitVersion.VersionCalculation.INextVersionCalculator.FindVersion() -> GitVersion.VersionCalculation.NextVersion! GitVersion.VersionCalculation.IVariableProvider @@ -970,6 +915,10 @@ GitVersion.VersionCalculation.IVersionFilter GitVersion.VersionCalculation.IVersionFilter.Exclude(GitVersion.VersionCalculation.BaseVersion! version, out string? reason) -> bool GitVersion.VersionCalculation.IVersionStrategy GitVersion.VersionCalculation.IVersionStrategy.GetBaseVersions(GitVersion.Configuration.EffectiveBranchConfiguration! configuration) -> System.Collections.Generic.IEnumerable! +GitVersion.VersionCalculation.IncrementStrategyFinder +GitVersion.VersionCalculation.IncrementStrategyFinder.DetermineIncrementedField(GitVersion.GitVersionContext! context, GitVersion.VersionCalculation.BaseVersion! baseVersion, GitVersion.Configuration.EffectiveConfiguration! configuration) -> GitVersion.VersionField +GitVersion.VersionCalculation.IncrementStrategyFinder.GetIncrementForCommits(GitVersion.Configuration.GitVersionConfiguration! configuration, System.Collections.Generic.IEnumerable! commits) -> GitVersion.VersionField? +GitVersion.VersionCalculation.IncrementStrategyFinder.IncrementStrategyFinder(GitVersion.IGitRepository! repository) -> void GitVersion.VersionCalculation.MergeMessageVersionStrategy GitVersion.VersionCalculation.MergeMessageVersionStrategy.MergeMessageVersionStrategy(GitVersion.Logging.ILog! log, System.Lazy! versionContext, GitVersion.Common.IRepositoryStore! repositoryStore) -> void GitVersion.VersionCalculation.MinDateVersionFilter @@ -1006,15 +955,15 @@ GitVersion.VersionCalculation.VersionCalculationModule.RegisterTypes(Microsoft.E GitVersion.VersionCalculation.VersionCalculationModule.VersionCalculationModule() -> void GitVersion.VersionCalculation.VersionInBranchNameVersionStrategy GitVersion.VersionCalculation.VersionInBranchNameVersionStrategy.VersionInBranchNameVersionStrategy(GitVersion.Common.IRepositoryStore! repositoryStore, System.Lazy! versionContext) -> void -GitVersion.VersionCalculation.VersioningMode -GitVersion.VersionCalculation.VersioningMode.ContinuousDelivery = 0 -> GitVersion.VersionCalculation.VersioningMode -GitVersion.VersionCalculation.VersioningMode.ContinuousDeployment = 1 -> GitVersion.VersionCalculation.VersioningMode -GitVersion.VersionCalculation.VersioningMode.Mainline = 2 -> GitVersion.VersionCalculation.VersioningMode GitVersion.VersionCalculation.VersionStrategyBase GitVersion.VersionCalculation.VersionStrategyBase.Context.get -> GitVersion.GitVersionContext! GitVersion.VersionCalculation.VersionStrategyBase.VersionStrategyBase(System.Lazy! versionContext) -> void GitVersion.VersionCalculation.VersionStrategyModule GitVersion.VersionCalculation.VersionStrategyModule.VersionStrategyModule() -> void +GitVersion.VersionCalculation.VersioningMode +GitVersion.VersionCalculation.VersioningMode.ContinuousDelivery = 0 -> GitVersion.VersionCalculation.VersioningMode +GitVersion.VersionCalculation.VersioningMode.ContinuousDeployment = 1 -> GitVersion.VersionCalculation.VersioningMode +GitVersion.VersionCalculation.VersioningMode.Mainline = 2 -> GitVersion.VersionCalculation.VersioningMode GitVersion.VersionConverters.AssemblyInfo.AssemblyInfoContext GitVersion.VersionConverters.AssemblyInfo.AssemblyInfoContext.AssemblyInfoContext() -> void GitVersion.VersionConverters.AssemblyInfo.AssemblyInfoContext.AssemblyInfoContext(string! workingDirectory, bool ensureAssemblyInfo, params string![]! assemblyInfoFiles) -> void @@ -1081,6 +1030,57 @@ GitVersion.WarningException.WarningException(string! message) -> void GitVersion.WixInfo GitVersion.WixInfo.ShouldUpdate -> bool GitVersion.WixInfo.WixInfo() -> void +abstract GitVersion.BuildAgents.BuildAgentBase.EnvironmentVariable.get -> string! +abstract GitVersion.BuildAgents.BuildAgentBase.GenerateSetParameterMessage(string! name, string! value) -> string![]! +abstract GitVersion.BuildAgents.BuildAgentBase.GenerateSetVersionMessage(GitVersion.OutputVariables.VersionVariables! variables) -> string? +abstract GitVersion.Configuration.Init.Wizard.ConfigInitWizardStep.DefaultResult.get -> string? +abstract GitVersion.Configuration.Init.Wizard.ConfigInitWizardStep.GetPrompt(GitVersion.Configuration.GitVersionConfiguration! configuration, string! workingDirectory) -> string! +abstract GitVersion.Configuration.Init.Wizard.ConfigInitWizardStep.HandleResult(string? result, System.Collections.Generic.Queue! steps, GitVersion.Configuration.GitVersionConfiguration! configuration, string! workingDirectory) -> GitVersion.Configuration.Init.StepResult! +abstract GitVersion.GitVersionModule.RegisterTypes(Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> void +abstract GitVersion.VersionCalculation.VersionStrategyBase.GetBaseVersions(GitVersion.Configuration.EffectiveBranchConfiguration! configuration) -> System.Collections.Generic.IEnumerable! +const GitVersion.BuildAgents.AppVeyor.EnvironmentVariableName = "APPVEYOR" -> string! +const GitVersion.BuildAgents.AzurePipelines.EnvironmentVariableName = "TF_BUILD" -> string! +const GitVersion.BuildAgents.BitBucketPipelines.BranchEnvironmentVariableName = "BITBUCKET_BRANCH" -> string! +const GitVersion.BuildAgents.BitBucketPipelines.EnvironmentVariableName = "BITBUCKET_WORKSPACE" -> string! +const GitVersion.BuildAgents.BitBucketPipelines.PullRequestEnvironmentVariableName = "BITBUCKET_PR_ID" -> string! +const GitVersion.BuildAgents.BitBucketPipelines.TagEnvironmentVariableName = "BITBUCKET_TAG" -> string! +const GitVersion.BuildAgents.BuildKite.EnvironmentVariableName = "BUILDKITE" -> string! +const GitVersion.BuildAgents.CodeBuild.SourceVersionEnvironmentVariableName = "CODEBUILD_SOURCE_VERSION" -> string! +const GitVersion.BuildAgents.CodeBuild.WebHookEnvironmentVariableName = "CODEBUILD_WEBHOOK_HEAD_REF" -> string! +const GitVersion.BuildAgents.ContinuaCi.EnvironmentVariableName = "ContinuaCI.Version" -> string! +const GitVersion.BuildAgents.Drone.EnvironmentVariableName = "DRONE" -> string! +const GitVersion.BuildAgents.EnvRun.EnvironmentVariableName = "ENVRUN_DATABASE" -> string! +const GitVersion.BuildAgents.GitHubActions.EnvironmentVariableName = "GITHUB_ACTIONS" -> string! +const GitVersion.BuildAgents.GitHubActions.GitHubSetEnvTempFileEnvironmentVariableName = "GITHUB_ENV" -> string! +const GitVersion.BuildAgents.GitLabCi.EnvironmentVariableName = "GITLAB_CI" -> string! +const GitVersion.BuildAgents.Jenkins.EnvironmentVariableName = "JENKINS_URL" -> string! +const GitVersion.BuildAgents.MyGet.EnvironmentVariableName = "BuildRunner" -> string! +const GitVersion.BuildAgents.SpaceAutomation.EnvironmentVariableName = "JB_SPACE_PROJECT_KEY" -> string! +const GitVersion.BuildAgents.TeamCity.EnvironmentVariableName = "TEAMCITY_VERSION" -> string! +const GitVersion.BuildAgents.TravisCi.EnvironmentVariableName = "TRAVIS" -> string! +const GitVersion.Configuration.ConfigurationFileLocator.DefaultFileName = "GitVersion.yml" -> string! +const GitVersion.Configuration.GitVersionConfiguration.DefaultLabelPrefix = "[vV]?" -> string! +const GitVersion.Configuration.GitVersionConfiguration.DevelopBranchKey = "develop" -> string! +const GitVersion.Configuration.GitVersionConfiguration.DevelopBranchRegex = "^dev(elop)?(ment)?$" -> string! +const GitVersion.Configuration.GitVersionConfiguration.FeatureBranchKey = "feature" -> string! +const GitVersion.Configuration.GitVersionConfiguration.FeatureBranchRegex = "^features?[/-]" -> string! +const GitVersion.Configuration.GitVersionConfiguration.HotfixBranchKey = "hotfix" -> string! +const GitVersion.Configuration.GitVersionConfiguration.HotfixBranchRegex = "^hotfix(es)?[/-]" -> string! +const GitVersion.Configuration.GitVersionConfiguration.MainBranchKey = "main" -> string! +const GitVersion.Configuration.GitVersionConfiguration.MainBranchRegex = "^master$|^main$" -> string! +const GitVersion.Configuration.GitVersionConfiguration.MasterBranchKey = "master" -> string! +const GitVersion.Configuration.GitVersionConfiguration.PullRequestBranchKey = "pull-request" -> string! +const GitVersion.Configuration.GitVersionConfiguration.PullRequestRegex = "^(pull|pull\\-requests|pr)[/-]" -> string! +const GitVersion.Configuration.GitVersionConfiguration.ReleaseBranchKey = "release" -> string! +const GitVersion.Configuration.GitVersionConfiguration.ReleaseBranchRegex = "^releases?[/-]" -> string! +const GitVersion.Configuration.GitVersionConfiguration.SupportBranchKey = "support" -> string! +const GitVersion.Configuration.GitVersionConfiguration.SupportBranchRegex = "^support[/-]" -> string! +const GitVersion.VersionCalculation.IncrementStrategyFinder.DefaultMajorPattern = "\\+semver:\\s?(breaking|major)" -> string! +const GitVersion.VersionCalculation.IncrementStrategyFinder.DefaultMinorPattern = "\\+semver:\\s?(feature|minor)" -> string! +const GitVersion.VersionCalculation.IncrementStrategyFinder.DefaultNoBumpPattern = "\\+semver:\\s?(none|skip)" -> string! +const GitVersion.VersionCalculation.IncrementStrategyFinder.DefaultPatchPattern = "\\+semver:\\s?(fix|patch)" -> string! +const GitVersion.VersionCalculation.MergeMessageVersionStrategy.MergeMessageStrategyPrefix = "Merge message" -> string! +const GitVersion.VersionConverters.WixUpdater.WixVersionFileUpdater.WixVersionFileName = "GitVersion_WixVersion.wxi" -> string! override GitVersion.BranchCommit.Equals(object? obj) -> bool override GitVersion.BranchCommit.GetHashCode() -> int override GitVersion.BuildAgents.AppVeyor.EnvironmentVariable.get -> string! @@ -1279,21 +1279,21 @@ static GitVersion.Extensions.ServiceCollectionExtensions.AddModule(this Microsof static GitVersion.Extensions.ServiceCollectionExtensions.GetServiceForType(this System.IServiceProvider! serviceProvider) -> TService static GitVersion.Extensions.StringExtensions.AppendLineFormat(this System.Text.StringBuilder! stringBuilder, string! format, params object![]! args) -> void static GitVersion.Extensions.StringExtensions.ArgumentRequiresValue(this string! argument, int argumentIndex) -> bool +static GitVersion.Extensions.StringExtensions.IsEmpty(this string? value) -> bool static GitVersion.Extensions.StringExtensions.IsEquivalentTo(this string! self, string? other) -> bool static GitVersion.Extensions.StringExtensions.IsFalse(this string? value) -> bool static GitVersion.Extensions.StringExtensions.IsHelp(this string! singleArgument) -> bool static GitVersion.Extensions.StringExtensions.IsInit(this string! singleArgument) -> bool static GitVersion.Extensions.StringExtensions.IsNullOrEmpty(this string? value) -> bool static GitVersion.Extensions.StringExtensions.IsNullOrWhiteSpace(this string? value) -> bool -static GitVersion.Extensions.StringExtensions.IsEmpty(this string? value) -> bool static GitVersion.Extensions.StringExtensions.IsSwitch(this string? value, string! switchName) -> bool static GitVersion.Extensions.StringExtensions.IsSwitchArgument(this string? value) -> bool static GitVersion.Extensions.StringExtensions.IsTrue(this string? value) -> bool static GitVersion.Extensions.StringExtensions.IsValidPath(this string? path) -> bool static GitVersion.Extensions.StringExtensions.RegexReplace(this string! input, string! pattern, string! replace, System.Text.RegularExpressions.RegexOptions options = System.Text.RegularExpressions.RegexOptions.None) -> string! static GitVersion.GitVersionModule.FindAllDerivedTypes(System.Reflection.Assembly? assembly) -> System.Collections.Generic.IEnumerable! -static GitVersion.Helpers.EncodingHelper.DetectEncoding(string? filename) -> System.Text.Encoding? static GitVersion.Helpers.EncodingHelper.DetectEncoding(System.Collections.Generic.IList! bytes) -> System.Text.Encoding? +static GitVersion.Helpers.EncodingHelper.DetectEncoding(string? filename) -> System.Text.Encoding? static GitVersion.Helpers.PathHelper.Combine(string? path1) -> string! static GitVersion.Helpers.PathHelper.Combine(string? path1, string? path2) -> string! static GitVersion.Helpers.PathHelper.Combine(string? path1, string? path2, string? path3) -> string! @@ -1335,19 +1335,20 @@ static GitVersion.OutputVariables.VersionVariables.FromFile(string! filePath, Gi static GitVersion.OutputVariables.VersionVariables.FromJson(string! json) -> GitVersion.OutputVariables.VersionVariables! static GitVersion.ReferenceName.FromBranchName(string! branchName) -> GitVersion.ReferenceName! static GitVersion.ReferenceName.Parse(string! canonicalName) -> GitVersion.ReferenceName! +static GitVersion.SemanticVersion.Parse(string! version, string? tagPrefixRegex, GitVersion.SemanticVersionFormat versionFormat = GitVersion.SemanticVersionFormat.Strict) -> GitVersion.SemanticVersion! +static GitVersion.SemanticVersion.TryParse(string! version, string? tagPrefixRegex, out GitVersion.SemanticVersion? semanticVersion, GitVersion.SemanticVersionFormat format = GitVersion.SemanticVersionFormat.Strict) -> bool static GitVersion.SemanticVersion.operator !=(GitVersion.SemanticVersion? v1, GitVersion.SemanticVersion? v2) -> bool static GitVersion.SemanticVersion.operator <(GitVersion.SemanticVersion! v1, GitVersion.SemanticVersion! v2) -> bool static GitVersion.SemanticVersion.operator <=(GitVersion.SemanticVersion! v1, GitVersion.SemanticVersion! v2) -> bool static GitVersion.SemanticVersion.operator ==(GitVersion.SemanticVersion? v1, GitVersion.SemanticVersion? v2) -> bool static GitVersion.SemanticVersion.operator >(GitVersion.SemanticVersion! v1, GitVersion.SemanticVersion! v2) -> bool static GitVersion.SemanticVersion.operator >=(GitVersion.SemanticVersion! v1, GitVersion.SemanticVersion! v2) -> bool -static GitVersion.SemanticVersion.Parse(string! version, string? tagPrefixRegex, GitVersion.SemanticVersionFormat versionFormat = GitVersion.SemanticVersionFormat.Strict) -> GitVersion.SemanticVersion! -static GitVersion.SemanticVersion.TryParse(string! version, string? tagPrefixRegex, out GitVersion.SemanticVersion? semanticVersion, GitVersion.SemanticVersionFormat format = GitVersion.SemanticVersionFormat.Strict) -> bool +static GitVersion.SemanticVersionBuildMetaData.Parse(string? buildMetaData) -> GitVersion.SemanticVersionBuildMetaData! static GitVersion.SemanticVersionBuildMetaData.implicit operator GitVersion.SemanticVersionBuildMetaData!(string! preReleaseTag) -> GitVersion.SemanticVersionBuildMetaData! static GitVersion.SemanticVersionBuildMetaData.implicit operator string?(GitVersion.SemanticVersionBuildMetaData? preReleaseTag) -> string? static GitVersion.SemanticVersionBuildMetaData.operator !=(GitVersion.SemanticVersionBuildMetaData? left, GitVersion.SemanticVersionBuildMetaData? right) -> bool static GitVersion.SemanticVersionBuildMetaData.operator ==(GitVersion.SemanticVersionBuildMetaData? left, GitVersion.SemanticVersionBuildMetaData? right) -> bool -static GitVersion.SemanticVersionBuildMetaData.Parse(string? buildMetaData) -> GitVersion.SemanticVersionBuildMetaData! +static GitVersion.SemanticVersionPreReleaseTag.Parse(string? preReleaseTag) -> GitVersion.SemanticVersionPreReleaseTag! static GitVersion.SemanticVersionPreReleaseTag.implicit operator GitVersion.SemanticVersionPreReleaseTag!(string? preReleaseTag) -> GitVersion.SemanticVersionPreReleaseTag! static GitVersion.SemanticVersionPreReleaseTag.implicit operator string?(GitVersion.SemanticVersionPreReleaseTag? preReleaseTag) -> string? static GitVersion.SemanticVersionPreReleaseTag.operator !=(GitVersion.SemanticVersionPreReleaseTag? left, GitVersion.SemanticVersionPreReleaseTag? right) -> bool @@ -1356,7 +1357,6 @@ static GitVersion.SemanticVersionPreReleaseTag.operator <=(GitVersion.SemanticVe static GitVersion.SemanticVersionPreReleaseTag.operator ==(GitVersion.SemanticVersionPreReleaseTag? left, GitVersion.SemanticVersionPreReleaseTag? right) -> bool static GitVersion.SemanticVersionPreReleaseTag.operator >(GitVersion.SemanticVersionPreReleaseTag? left, GitVersion.SemanticVersionPreReleaseTag? right) -> bool static GitVersion.SemanticVersionPreReleaseTag.operator >=(GitVersion.SemanticVersionPreReleaseTag? left, GitVersion.SemanticVersionPreReleaseTag? right) -> bool -static GitVersion.SemanticVersionPreReleaseTag.Parse(string? preReleaseTag) -> GitVersion.SemanticVersionPreReleaseTag! static GitVersion.VersionCalculation.NextVersion.operator !=(GitVersion.VersionCalculation.NextVersion! left, GitVersion.VersionCalculation.NextVersion! right) -> bool static GitVersion.VersionCalculation.NextVersion.operator <(GitVersion.VersionCalculation.NextVersion! left, GitVersion.VersionCalculation.NextVersion! right) -> bool static GitVersion.VersionCalculation.NextVersion.operator <=(GitVersion.VersionCalculation.NextVersion! left, GitVersion.VersionCalculation.NextVersion! right) -> bool @@ -1378,4 +1378,4 @@ virtual GitVersion.Configuration.IgnoreConfiguration.ToFilters() -> System.Colle virtual GitVersion.VersionCalculation.EffectiveBranchConfigurationFinder.GetConfigurations(GitVersion.IBranch! branch, GitVersion.Configuration.GitVersionConfiguration! configuration) -> System.Collections.Generic.IEnumerable! virtual GitVersion.VersionCalculation.FallbackVersionStrategy.GetBaseVersions(GitVersion.Configuration.EffectiveBranchConfiguration! configuration) -> System.Collections.Generic.IEnumerable! virtual GitVersion.VersionCalculation.NextVersionCalculator.FindVersion() -> GitVersion.VersionCalculation.NextVersion! -virtual GitVersion.VersionCalculation.TaggedCommitVersionStrategy.FormatSource(GitVersion.VersionCalculation.TaggedCommitVersionStrategy.VersionTaggedCommit! version) -> string! +virtual GitVersion.VersionCalculation.TaggedCommitVersionStrategy.FormatSource(GitVersion.VersionCalculation.TaggedCommitVersionStrategy.VersionTaggedCommit! version) -> string! \ No newline at end of file diff --git a/src/GitVersion.Core/VersionCalculation/MainlineVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/MainlineVersionCalculator.cs index 237a1d48e0..e177b90732 100644 --- a/src/GitVersion.Core/VersionCalculation/MainlineVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/MainlineVersionCalculator.cs @@ -23,7 +23,7 @@ public MainlineVersionCalculator(ILog log, IRepositoryStore repositoryStore, Laz public SemanticVersion FindMainlineModeVersion(BaseVersion baseVersion) { - if (baseVersion.SemanticVersion.PreReleaseTag?.HasTag() == true) + if (baseVersion.SemanticVersion.PreReleaseTag.HasTag() == true) { throw new NotSupportedException("Mainline development mode doesn't yet support pre-release tags on main"); } diff --git a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs index a6b8ebf9a5..572128e97f 100644 --- a/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs +++ b/src/GitVersion.Core/VersionCalculation/NextVersionCalculator.cs @@ -56,7 +56,7 @@ public virtual NextVersion FindVersion() { var baseVersionBuildMetaData = this.mainlineVersionCalculator.CreateVersionBuildMetaData(baseVersion.BaseVersionSource); - if (baseVersionBuildMetaData.Sha != nextVersion.IncrementedVersion.BuildMetaData?.Sha) + if (baseVersionBuildMetaData.Sha != nextVersion.IncrementedVersion.BuildMetaData.Sha) { semver = nextVersion.IncrementedVersion; } @@ -69,8 +69,8 @@ public virtual NextVersion FindVersion() var lastPrefixedSemver = this.repositoryStore .GetVersionTagsOnBranch(Context.CurrentBranch, Context.Configuration.LabelPrefix, Context.Configuration.SemanticVersionFormat) - .Where(v => MajorMinorPatchEqual(v, semver) && v.PreReleaseTag?.HasTag() == true) - .FirstOrDefault(v => v.PreReleaseTag?.Name?.IsEquivalentTo(preReleaseTagName) == true); + .Where(v => MajorMinorPatchEqual(v, semver) && v.PreReleaseTag.HasTag() == true) + .FirstOrDefault(v => v.PreReleaseTag.Name?.IsEquivalentTo(preReleaseTagName) == true); if (lastPrefixedSemver != null) { @@ -87,7 +87,7 @@ public virtual NextVersion FindVersion() { long? number; - if (semver.PreReleaseTag?.Name == preReleaseTagName) + if (semver.PreReleaseTag.Name == preReleaseTagName) { number = semver.PreReleaseTag.Number + 1; } @@ -214,7 +214,7 @@ private IEnumerable GetNextVersions(IBranch branch, GitVersionConfi if (configuration.VersioningMode == VersioningMode.Mainline) { - if (incrementedVersion.PreReleaseTag?.HasTag() == true) + if (!(incrementedVersion.PreReleaseTag.HasTag() != true)) { continue; } diff --git a/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersion.cs b/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersion.cs index 91dd146914..89188a57ff 100644 --- a/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersion.cs +++ b/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersion.cs @@ -21,10 +21,10 @@ public class SemanticVersion : IFormattable, IComparable, IEqua public long Major; public long Minor; public long Patch; - public SemanticVersionPreReleaseTag? PreReleaseTag; - public SemanticVersionBuildMetaData? BuildMetaData; + public SemanticVersionPreReleaseTag PreReleaseTag; + public SemanticVersionBuildMetaData BuildMetaData; - public bool HasPreReleaseTagWithLabel => PreReleaseTag?.HasTag() == true; + public bool HasPreReleaseTagWithLabel => PreReleaseTag.HasTag() == true; public SemanticVersion(long major = 0, long minor = 0, long patch = 0) { @@ -76,8 +76,8 @@ public override int GetHashCode() var hashCode = this.Major.GetHashCode(); hashCode = (hashCode * 397) ^ this.Minor.GetHashCode(); hashCode = (hashCode * 397) ^ this.Patch.GetHashCode(); - hashCode = (hashCode * 397) ^ (this.PreReleaseTag != null ? this.PreReleaseTag.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.BuildMetaData != null ? this.BuildMetaData.GetHashCode() : 0); + hashCode = (hashCode * 397) ^ this.PreReleaseTag.GetHashCode(); + hashCode = (hashCode * 397) ^ this.BuildMetaData.GetHashCode(); return hashCode; } } @@ -278,18 +278,18 @@ public string ToString(string? format, IFormatProvider? formatProvider) case "j": return $"{this.Major}.{this.Minor}.{this.Patch}"; case "s": - return this.PreReleaseTag?.HasTag() == true ? $"{ToString("j")}-{this.PreReleaseTag}" : ToString("j"); + return this.PreReleaseTag.HasTag() == true ? $"{ToString("j")}-{this.PreReleaseTag}" : ToString("j"); case "t": - return this.PreReleaseTag?.HasTag() == true ? $"{ToString("j")}-{this.PreReleaseTag.ToString("t")}" : ToString("j"); + return this.PreReleaseTag.HasTag() == true ? $"{ToString("j")}-{this.PreReleaseTag.ToString("t")}" : ToString("j"); case "f": { - var buildMetadata = this.BuildMetaData?.ToString(); + var buildMetadata = this.BuildMetaData.ToString(); return !buildMetadata.IsNullOrEmpty() ? $"{ToString("s")}+{buildMetadata}" : ToString("s"); } case "i": { - var buildMetadata = this.BuildMetaData?.ToString("f"); + var buildMetadata = this.BuildMetaData.ToString("f"); return !buildMetadata.IsNullOrEmpty() ? $"{ToString("s")}+{buildMetadata}" : ToString("s"); } @@ -301,7 +301,7 @@ public string ToString(string? format, IFormatProvider? formatProvider) public SemanticVersion IncrementVersion(VersionField incrementStrategy) { var incremented = new SemanticVersion(this); - if (incremented.PreReleaseTag?.HasTag() != true) + if (incremented.PreReleaseTag.HasTag() != true) { switch (incrementStrategy) { diff --git a/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs b/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs index f6385088c6..e451ead9f3 100644 --- a/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs +++ b/src/GitVersion.Core/VersionCalculation/SemanticVersioning/SemanticVersionFormatValues.cs @@ -23,19 +23,19 @@ public SemanticVersionFormatValues(SemanticVersion semver, EffectiveConfiguratio public string? PreReleaseTag => this.semver.PreReleaseTag; - public string? PreReleaseTagWithDash => this.semver.PreReleaseTag?.HasTag() == true ? "-" + this.semver.PreReleaseTag : null; + public string? PreReleaseTagWithDash => this.semver.PreReleaseTag.HasTag() == true ? "-" + this.semver.PreReleaseTag : null; - public string? PreReleaseLabel => this.semver.PreReleaseTag?.HasTag() == true ? this.semver.PreReleaseTag.Name : null; + public string? PreReleaseLabel => this.semver.PreReleaseTag.HasTag() == true ? this.semver.PreReleaseTag.Name : null; - public string? PreReleaseLabelWithDash => this.semver.PreReleaseTag?.HasTag() == true ? "-" + this.semver.PreReleaseTag.Name : null; + public string? PreReleaseLabelWithDash => this.semver.PreReleaseTag.HasTag() == true ? "-" + this.semver.PreReleaseTag.Name : null; - public string? PreReleaseNumber => this.semver.PreReleaseTag?.HasTag() == true ? this.semver.PreReleaseTag.Number.ToString() : null; + public string? PreReleaseNumber => this.semver.PreReleaseTag.HasTag() == true ? this.semver.PreReleaseTag.Number.ToString() : null; public string WeightedPreReleaseNumber => GetWeightedPreReleaseNumber(); public string? BuildMetaData => this.semver.BuildMetaData; - public string? FullBuildMetaData => this.semver.BuildMetaData?.ToString("f"); + public string? FullBuildMetaData => this.semver.BuildMetaData.ToString("f"); public string MajorMinorPatch => $"{this.semver.Major}.{this.semver.Minor}.{this.semver.Patch}"; @@ -47,28 +47,28 @@ public SemanticVersionFormatValues(SemanticVersion semver, EffectiveConfiguratio public string FullSemVer => this.semver.ToString("f"); - public string? BranchName => this.semver.BuildMetaData?.Branch; + public string? BranchName => this.semver.BuildMetaData.Branch; - public string? EscapedBranchName => this.semver.BuildMetaData?.Branch?.RegexReplace("[^a-zA-Z0-9-]", "-"); + public string? EscapedBranchName => this.semver.BuildMetaData.Branch?.RegexReplace("[^a-zA-Z0-9-]", "-"); - public string? Sha => this.semver.BuildMetaData?.Sha; + public string? Sha => this.semver.BuildMetaData.Sha; - public string? ShortSha => this.semver.BuildMetaData?.ShortSha; + public string? ShortSha => this.semver.BuildMetaData.ShortSha; - public string? CommitDate => this.semver.BuildMetaData?.CommitDate?.UtcDateTime.ToString(this.configuration.CommitDateFormat, CultureInfo.InvariantCulture); + public string? CommitDate => this.semver.BuildMetaData.CommitDate?.UtcDateTime.ToString(this.configuration.CommitDateFormat, CultureInfo.InvariantCulture); public string InformationalVersion => this.semver.ToString("i"); - public string? VersionSourceSha => this.semver.BuildMetaData?.VersionSourceSha; + public string? VersionSourceSha => this.semver.BuildMetaData.VersionSourceSha; - public string? CommitsSinceVersionSource => this.semver.BuildMetaData?.CommitsSinceVersionSource?.ToString(CultureInfo.InvariantCulture); + public string? CommitsSinceVersionSource => this.semver.BuildMetaData.CommitsSinceVersionSource?.ToString(CultureInfo.InvariantCulture); - public string? UncommittedChanges => this.semver.BuildMetaData?.UncommittedChanges.ToString(CultureInfo.InvariantCulture); + public string? UncommittedChanges => this.semver.BuildMetaData.UncommittedChanges.ToString(CultureInfo.InvariantCulture); private string GetWeightedPreReleaseNumber() { var weightedPreReleaseNumber = - this.semver.PreReleaseTag?.HasTag() == true ? (this.semver.PreReleaseTag.Number + this.configuration.PreReleaseWeight).ToString() : null; + this.semver.PreReleaseTag.HasTag() == true ? (this.semver.PreReleaseTag.Number + this.configuration.PreReleaseWeight).ToString() : null; return weightedPreReleaseNumber.IsNullOrEmpty() ? $"{this.configuration.LabelPreReleaseWeight}" diff --git a/src/GitVersion.Core/VersionCalculation/VariableProvider.cs b/src/GitVersion.Core/VersionCalculation/VariableProvider.cs index b7e645501d..3057da61bb 100644 --- a/src/GitVersion.Core/VersionCalculation/VariableProvider.cs +++ b/src/GitVersion.Core/VersionCalculation/VariableProvider.cs @@ -25,9 +25,9 @@ public VersionVariables GetVariablesFor(SemanticVersion semanticVersion, Effecti { semanticVersion = new SemanticVersion(semanticVersion); // Continuous Deployment always requires a pre-release tag unless the commit is tagged - if (semanticVersion.PreReleaseTag != null && semanticVersion.PreReleaseTag.HasTag() != true) + if (semanticVersion.PreReleaseTag.HasTag() != true) { - semanticVersion.PreReleaseTag.Name = configuration.GetBranchSpecificTag(this.log, semanticVersion.BuildMetaData?.Branch, null); + semanticVersion.PreReleaseTag.Name = configuration.GetBranchSpecificTag(this.log, semanticVersion.BuildMetaData.Branch, null); if (semanticVersion.PreReleaseTag.Name.IsNullOrEmpty()) { // TODO: Why do we manipulating the semantic version here in the VariableProvider? The method name is GET not MANIPULATE. @@ -38,14 +38,14 @@ public VersionVariables GetVariablesFor(SemanticVersion semanticVersion, Effecti } // Evaluate tag number pattern and append to prerelease tag, preserving build metadata - var appendTagNumberPattern = !configuration.LabelNumberPattern.IsNullOrEmpty() && semanticVersion.PreReleaseTag?.HasTag() == true; + var appendTagNumberPattern = !configuration.LabelNumberPattern.IsNullOrEmpty() && semanticVersion.PreReleaseTag.HasTag() == true; if (appendTagNumberPattern) { - if (semanticVersion.BuildMetaData?.Branch != null && configuration.LabelNumberPattern != null) + if (semanticVersion.BuildMetaData.Branch != null && configuration.LabelNumberPattern != null) { var match = Regex.Match(semanticVersion.BuildMetaData.Branch, configuration.LabelNumberPattern); var numberGroup = match.Groups["number"]; - if (numberGroup.Success && semanticVersion.PreReleaseTag != null) + if (numberGroup.Success) { // TODO: Why do we manipulating the semantic version here in the VariableProvider? The method name is GET not MANIPULATE. // What is about the separation of concern and single-responsibility principle? @@ -101,29 +101,26 @@ public VersionVariables GetVariablesFor(SemanticVersion semanticVersion, Effecti private static void PromoteNumberOfCommitsToTagNumber(SemanticVersion semanticVersion) { - if (semanticVersion.PreReleaseTag != null && semanticVersion.BuildMetaData != null) + // For continuous deployment the commits since tag gets promoted to the pre-release number + if (!semanticVersion.BuildMetaData.CommitsSinceTag.HasValue) { - // For continuous deployment the commits since tag gets promoted to the pre-release number - if (!semanticVersion.BuildMetaData.CommitsSinceTag.HasValue) + semanticVersion.PreReleaseTag.Number = null; + semanticVersion.BuildMetaData.CommitsSinceVersionSource = 0; + } + else + { + // Number of commits since last tag should be added to PreRelease number if given. Remember to deduct automatic version bump. + if (semanticVersion.PreReleaseTag.Number.HasValue) { - semanticVersion.PreReleaseTag.Number = null; - semanticVersion.BuildMetaData.CommitsSinceVersionSource = 0; + semanticVersion.PreReleaseTag.Number += semanticVersion.BuildMetaData.CommitsSinceTag - 1; } else { - // Number of commits since last tag should be added to PreRelease number if given. Remember to deduct automatic version bump. - if (semanticVersion.PreReleaseTag.Number.HasValue) - { - semanticVersion.PreReleaseTag.Number += semanticVersion.BuildMetaData.CommitsSinceTag - 1; - } - else - { - semanticVersion.PreReleaseTag.Number = semanticVersion.BuildMetaData.CommitsSinceTag; - semanticVersion.PreReleaseTag.PromotedFromCommits = true; - } - semanticVersion.BuildMetaData.CommitsSinceVersionSource = semanticVersion.BuildMetaData.CommitsSinceTag.Value; - semanticVersion.BuildMetaData.CommitsSinceTag = null; // why is this set to null ? + semanticVersion.PreReleaseTag.Number = semanticVersion.BuildMetaData.CommitsSinceTag; + semanticVersion.PreReleaseTag.PromotedFromCommits = true; } + semanticVersion.BuildMetaData.CommitsSinceVersionSource = semanticVersion.BuildMetaData.CommitsSinceTag.Value; + semanticVersion.BuildMetaData.CommitsSinceTag = null; // why is this set to null ? } }