diff --git a/src/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs b/src/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs index 5764df9783..699805c441 100644 --- a/src/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs +++ b/src/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs @@ -131,6 +131,7 @@ public void AssertFullSemver(string fullSemver, IRepository repository = null, s { if (repository != null) repository.DumpGraph(); + throw; } if (commitId == null) diagramBuilder.AppendLineFormat("note over {0} #D3D3D3: {1}", GetParticipant(Repository.Head.Name), fullSemver); diff --git a/src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs b/src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs index 28d28821c5..b9be9f5a8a 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/DocumentationSamples.cs @@ -139,7 +139,7 @@ public void GitFlowMinorRelease() // Make a commit after a tag should bump up the beta fixture.MakeACommit(); - fixture.AssertFullSemver("1.3.0-beta.2+1"); + fixture.AssertFullSemver("1.3.0-beta.2+2"); // Complete release fixture.Checkout("master"); @@ -195,7 +195,7 @@ public void GitFlowMajorRelease() // Make a commit after a tag should bump up the beta fixture.MakeACommit(); - fixture.AssertFullSemver("2.0.0-beta.2+1"); + fixture.AssertFullSemver("2.0.0-beta.2+2"); // Complete release fixture.Checkout("master"); @@ -392,7 +392,7 @@ public void GitHubFlowMajorRelease() // Make a commit after a tag should bump up the beta fixture.MakeACommit(); - fixture.AssertFullSemver("2.0.0-beta.2+1"); + fixture.AssertFullSemver("2.0.0-beta.2+3"); // Complete release fixture.Checkout("master"); diff --git a/src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs index 56852dcd2d..aa2ac91588 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/ReleaseBranchScenarios.cs @@ -205,7 +205,7 @@ public void WhenReleaseBranchIsMergedIntoDevelopHighestVersionIsTakenWithIt() fixture.Repository.Checkout("develop"); fixture.Repository.MergeNoFF("release-1.0.0", Constants.SignatureNow()); - fixture.AssertFullSemver("2.1.0-unstable.0"); + fixture.AssertFullSemver("2.1.0-unstable.5"); } } @@ -256,7 +256,7 @@ public void WhenMergingReleaseBackToDevShouldNotResetBetaVersion() fixture.Repository.MakeCommits(1); - fixture.AssertFullSemver("2.0.0-beta.2+1"); + fixture.AssertFullSemver("2.0.0-beta.2+2"); //merge down to develop fixture.Repository.Checkout("develop"); @@ -264,7 +264,45 @@ public void WhenMergingReleaseBackToDevShouldNotResetBetaVersion() //but keep working on the release fixture.Repository.Checkout("release-2.0.0"); - fixture.AssertFullSemver("2.0.0-beta.2+1"); + fixture.AssertFullSemver("2.0.0-beta.2+2"); + } + } + + [Test] + public void HotfixOffReleaseBranchShouldNotResetCount() + { + using (var fixture = new EmptyRepositoryFixture(new Config + { + VersioningMode = VersioningMode.ContinuousDeployment + })) + { + const string TaggedVersion = "1.0.3"; + fixture.Repository.MakeATaggedCommit(TaggedVersion); + fixture.Repository.CreateBranch("develop"); + fixture.Repository.Checkout("develop"); + + fixture.Repository.MakeCommits(1); + + fixture.Repository.CreateBranch("release-2.0.0"); + fixture.Repository.Checkout("release-2.0.0"); + fixture.Repository.MakeCommits(1); + + fixture.AssertFullSemver("2.0.0-beta.1"); + + //tag it to bump to beta 2 + fixture.Repository.MakeCommits(4); + + fixture.AssertFullSemver("2.0.0-beta.5"); + + //merge down to develop + fixture.Repository.CreateBranch("hotfix-2.0.0"); + fixture.Repository.MakeCommits(2); + + //but keep working on the release + fixture.Repository.Checkout("release-2.0.0"); + fixture.Repository.MergeNoFF("hotfix-2.0.0", Constants.SignatureNow()); + fixture.Repository.Branches.Remove(fixture.Repository.FindBranch("hotfix-2.0.0")); + fixture.AssertFullSemver("2.0.0-beta.7"); } } } \ No newline at end of file diff --git a/src/GitVersionCore.Tests/IntegrationTests/SupportBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/SupportBranchScenarios.cs index 7efcd1f7c2..1bf435a5ca 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/SupportBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/SupportBranchScenarios.cs @@ -69,7 +69,7 @@ public void WhenSupportIsBranchedAndTaggedFromAnotherSupportEnsureNewMinorIsUsed fixture.Repository.MakeACommit(); fixture.Repository.MakeACommit(); - fixture.AssertFullSemver("1.3.0+2"); + fixture.AssertFullSemver("1.3.1+2"); } } } \ No newline at end of file diff --git a/src/GitVersionCore/VersionCalculation/BaseVersionCalculator.cs b/src/GitVersionCore/VersionCalculation/BaseVersionCalculator.cs index f2abebadf7..efe2888588 100644 --- a/src/GitVersionCore/VersionCalculation/BaseVersionCalculator.cs +++ b/src/GitVersionCore/VersionCalculation/BaseVersionCalculator.cs @@ -53,7 +53,7 @@ public BaseVersion GetBaseVersion(GitVersionContext context) { baseVersionWithOldestSource = baseVersions .Where(v => v.Version.BaseVersionSource != null) - .OrderBy(v => v.IncrementedVersion) + .OrderByDescending(v => v.IncrementedVersion) .ThenByDescending(v => v.Version.BaseVersionSource.Committer.When) .First() .Version;