From fe5158a95dfa9b636c4ac02f880a23c00a066027 Mon Sep 17 00:00:00 2001 From: Gerwin Jansen Date: Fri, 25 Sep 2020 14:13:12 +0200 Subject: [PATCH 1/2] Allow building from a detached tag, since there is no need to calculate the increment --- .../IntegrationTests/TagCheckoutScenarios.cs | 32 +++++++++++++++++++ .../NextVersionCalculator.cs | 5 ++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 src/GitVersionCore.Tests/IntegrationTests/TagCheckoutScenarios.cs diff --git a/src/GitVersionCore.Tests/IntegrationTests/TagCheckoutScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/TagCheckoutScenarios.cs new file mode 100644 index 0000000000..5a87fc65c2 --- /dev/null +++ b/src/GitVersionCore.Tests/IntegrationTests/TagCheckoutScenarios.cs @@ -0,0 +1,32 @@ +using GitTools.Testing; +using NUnit.Framework; + +namespace GitVersionCore.Tests.IntegrationTests +{ + [TestFixture] + public class TagCheckoutScenarios + { + [Test] + public void GivenARepositoryWithSingleCommit() + { + using var fixture = new EmptyRepositoryFixture(); + const string taggedVersion = "1.0.3"; + fixture.Repository.MakeATaggedCommit(taggedVersion); + fixture.Checkout(taggedVersion); + + fixture.AssertFullSemver(taggedVersion); + } + + [Test] + public void GivenARepositoryWithSingleCommitAndSingleBranch() + { + using var fixture = new EmptyRepositoryFixture(); + const string taggedVersion = "1.0.3"; + fixture.Repository.MakeATaggedCommit(taggedVersion); + fixture.BranchTo("task1"); + fixture.Checkout(taggedVersion); + + fixture.AssertFullSemver(taggedVersion); + } + } +} diff --git a/src/GitVersionCore/VersionCalculation/NextVersionCalculator.cs b/src/GitVersionCore/VersionCalculation/NextVersionCalculator.cs index 8a2a0361ca..15dbbbbb1c 100644 --- a/src/GitVersionCore/VersionCalculation/NextVersionCalculator.cs +++ b/src/GitVersionCore/VersionCalculation/NextVersionCalculator.cs @@ -35,7 +35,10 @@ public SemanticVersion FindVersion() log.Info($"Current commit is tagged with version {context.CurrentCommitTaggedVersion}, " + "version calculation is for metadata only."); } - EnsureHeadIsNotDetached(context); + else + { + EnsureHeadIsNotDetached(context); + } SemanticVersion taggedSemanticVersion = null; From 72a0cfd69f9cbdb7f4f13e4f62db21eb5201bb06 Mon Sep 17 00:00:00 2001 From: Gerwin Jansen Date: Fri, 25 Sep 2020 14:49:14 +0200 Subject: [PATCH 2/2] Removed UTF-8 BOM --- .../IntegrationTests/TagCheckoutScenarios.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GitVersionCore.Tests/IntegrationTests/TagCheckoutScenarios.cs b/src/GitVersionCore.Tests/IntegrationTests/TagCheckoutScenarios.cs index 5a87fc65c2..53f524871e 100644 --- a/src/GitVersionCore.Tests/IntegrationTests/TagCheckoutScenarios.cs +++ b/src/GitVersionCore.Tests/IntegrationTests/TagCheckoutScenarios.cs @@ -1,4 +1,4 @@ -using GitTools.Testing; +using GitTools.Testing; using NUnit.Framework; namespace GitVersionCore.Tests.IntegrationTests