Skip to content

Commit fb9c26d

Browse files
committed
Removed the GitVersionContext constructor which leads to issues when a given commit is on multiple branches and the desired branch is not specified
1 parent dfa6c79 commit fb9c26d

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed

src/GitVersionCore.Tests/GitVersionContextBuilder.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ public GitVersionContext Build()
6161
{
6262
var configuration = config ?? new Config();
6363
ConfigurationProvider.ApplyDefaultsTo(configuration);
64-
return new GitVersionContext(repository ?? CreateRepository(), configuration);
64+
var repo = repository ?? CreateRepository();
65+
return new GitVersionContext(repo, repo.Head, configuration);
6566
}
6667

6768
IRepository CreateRepository()

src/GitVersionCore.Tests/GitVersionContextTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public void CanFindParentBranchForInheritingIncrementStrategy()
144144
Commands.Checkout(repo.Repository, featureBranch);
145145
repo.Repository.MakeACommit();
146146

147-
var context = new GitVersionContext(repo.Repository, config);
147+
var context = new GitVersionContext(repo.Repository, repo.Repository.Head, config);
148148
context.Configuration.Increment.ShouldBe(IncrementStrategy.Major);
149149
}
150150
}

src/GitVersionCore/GitVersionContext.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
/// </summary>
1010
public class GitVersionContext
1111
{
12-
public GitVersionContext(IRepository repository, Config configuration, bool isForTrackingBranchOnly = true, string commitId = null)
13-
: this(repository, repository.Head, configuration, isForTrackingBranchOnly, commitId)
14-
{
15-
}
16-
1712
public GitVersionContext(IRepository repository, string targetBranch, Config configuration, bool onlyEvaluateTrackedBranches = true, string commitId = null)
1813
: this(repository, repository.Branches.SingleOrDefault(b => b.CanonicalName == targetBranch || b.FriendlyName == targetBranch) ?? repository.Head, configuration, onlyEvaluateTrackedBranches, commitId)
1914
{

0 commit comments

Comments
 (0)