Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow building from a detached tag, since there is no need to calculate the increment #2411

Merged
merged 4 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/GitVersionCore.Tests/IntegrationTests/TagCheckoutScenarios.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down