From cbaa5394fdc9c34216aca7c7dd4a604499615a12 Mon Sep 17 00:00:00 2001 From: lerthe61 Date: Tue, 17 May 2016 09:17:44 +0300 Subject: [PATCH] #862 Unit test to test that version calculation does not use tags from not merged branch --- .../IntegrationTests/OtherBranchScenarios.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/GitVersionCore.Tests/IntegrationTests/OtherBranchScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/OtherBranchScenarios.cs index fee217343c..19df76ced8 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/OtherBranchScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/OtherBranchScenarios.cs @@ -2,6 +2,7 @@ using GitVersionCore.Tests; using LibGit2Sharp; using NUnit.Framework; +using Shouldly; [TestFixture] public class OtherBranchScenarios @@ -20,6 +21,7 @@ public void CanTakeVersionFromReleaseBranch() fixture.AssertFullSemver("2.0.0-alpha.1+0"); } } + [Test] public void BranchesWithIllegalCharsShouldNotBeUsedInVersionNames() { @@ -34,4 +36,25 @@ public void BranchesWithIllegalCharsShouldNotBeUsedInVersionNames() fixture.AssertFullSemver("1.0.4-issue-m-github-569.1+5"); } } + + [Test] + public void ShouldNotGetVersionFromFeatureBranchIfNotMerged() + { + using (var fixture = new EmptyRepositoryFixture()) + { + fixture.Repository.MakeATaggedCommit("1.0.0-unstable.0"); // initial commit in master + + fixture.Repository.CreateBranch("feature"); + fixture.Repository.Checkout("feature"); + fixture.Repository.MakeATaggedCommit("1.0.1-feature.1"); + + fixture.Repository.Checkout("master"); + fixture.Repository.CreateBranch("develop"); + fixture.Repository.Checkout("develop"); + fixture.Repository.MakeACommit(); + + var version = fixture.GetVersion(); + version.SemVer.ShouldBe("1.0.0-unstable.1"); + } + } } \ No newline at end of file