Skip to content

Commit 124b89c

Browse files
authored
Merge pull request #2411 from gerwinjansen/allow-building-from-detached-tag
Allow building from a detached tag, since there is no need to calculate the increment
2 parents c563b15 + 4fd9550 commit 124b89c

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using GitTools.Testing;
2+
using NUnit.Framework;
3+
4+
namespace GitVersionCore.Tests.IntegrationTests
5+
{
6+
[TestFixture]
7+
public class TagCheckoutScenarios
8+
{
9+
[Test]
10+
public void GivenARepositoryWithSingleCommit()
11+
{
12+
using var fixture = new EmptyRepositoryFixture();
13+
const string taggedVersion = "1.0.3";
14+
fixture.Repository.MakeATaggedCommit(taggedVersion);
15+
fixture.Checkout(taggedVersion);
16+
17+
fixture.AssertFullSemver(taggedVersion);
18+
}
19+
20+
[Test]
21+
public void GivenARepositoryWithSingleCommitAndSingleBranch()
22+
{
23+
using var fixture = new EmptyRepositoryFixture();
24+
const string taggedVersion = "1.0.3";
25+
fixture.Repository.MakeATaggedCommit(taggedVersion);
26+
fixture.BranchTo("task1");
27+
fixture.Checkout(taggedVersion);
28+
29+
fixture.AssertFullSemver(taggedVersion);
30+
}
31+
}
32+
}

src/GitVersionCore/VersionCalculation/NextVersionCalculator.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ public SemanticVersion FindVersion()
3535
log.Info($"Current commit is tagged with version {context.CurrentCommitTaggedVersion}, " +
3636
"version calculation is for metadata only.");
3737
}
38-
EnsureHeadIsNotDetached(context);
38+
else
39+
{
40+
EnsureHeadIsNotDetached(context);
41+
}
3942

4043
SemanticVersion taggedSemanticVersion = null;
4144

0 commit comments

Comments
 (0)