Skip to content

Commit

Permalink
Merge pull request #541 from JakeGinnivan/CommitCountingFixes
Browse files Browse the repository at this point in the history
Fixing issues introduced with commit counting
  • Loading branch information
JakeGinnivan committed Jul 28, 2015
2 parents 8c6ab50 + 9a2811a commit 93ad627
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/GitVersionCore.Tests/Fixtures/RepositoryFixtureBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}

Expand Down Expand Up @@ -256,15 +256,53 @@ 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");
fixture.Repository.MergeNoFF("release-2.0.0", Constants.SignatureNow());

//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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 93ad627

Please sign in to comment.