Skip to content
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
19 changes: 19 additions & 0 deletions src/GitVersionCore.Tests/IntegrationTests/TagCheckoutScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,24 @@ public void GivenARepositoryWithSingleCommitAndSingleBranch()

fixture.AssertFullSemver(taggedVersion);
}

[Test]
public void GivenARepositoryWithTwoTagsAndADevelopBranch()
{
using var fixture = new EmptyRepositoryFixture();
const string firstVersion = "1.0";
const string hotfixVersion = "1.0.1";

fixture.MakeACommit("init master");
fixture.ApplyTag(firstVersion);
fixture.MakeACommit("hotfix");
fixture.ApplyTag(hotfixVersion);
fixture.BranchTo("develop");
fixture.MakeACommit("new feature");
fixture.Checkout(hotfixVersion);
fixture.BranchTo("tags/1.0.1");

fixture.AssertFullSemver(hotfixVersion);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal IEnumerable<BaseVersion> GetTaggedVersions(Branch currentBranch, DateTi
{
var allTags = repositoryMetadataProvider.GetValidVersionTags(Context.Configuration.GitTagPrefix, olderThan);

var tagsOnBranch = currentBranch
var taggedVersions = currentBranch
.Commits
.SelectMany(commit => { return allTags.Where(t => IsValidTag(t.Item1, commit)); })
.Select(t =>
Expand All @@ -40,11 +40,12 @@ internal IEnumerable<BaseVersion> GetTaggedVersions(Branch currentBranch, DateTi

return null;
})
.Where(a => a != null)
.Take(5)
.Where(versionTaggedCommit => versionTaggedCommit != null)
.Select(versionTaggedCommit => CreateBaseVersion(Context, versionTaggedCommit))
.ToList();

return tagsOnBranch.Select(t => CreateBaseVersion(Context, t));
var taggedVersionsOnCurrentCommit = taggedVersions.Where(version => !version.ShouldIncrement).ToList();
return taggedVersionsOnCurrentCommit.Any() ? taggedVersionsOnCurrentCommit : taggedVersions;
}

private BaseVersion CreateBaseVersion(GitVersionContext context, VersionTaggedCommit version)
Expand Down