Skip to content

Commit 179870b

Browse files
committed
Fixed wrong implementation of parameter onlyTrackedBranches in GetBranchesContainingCommit(...) and adapted logic of existing functionality to restore correct behaviour
1 parent cfdc119 commit 179870b

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

src/GitVersionCore/Configuration/BranchConfigurationCalculator.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public BranchConfigurationCalculator(ILog log, GitVersionContext context)
2626
public BranchConfig GetBranchConfiguration(Branch targetBranch, IList<Branch> excludedInheritBranches = null)
2727
{
2828
var matchingBranches = context.FullConfiguration.GetConfigForBranch(targetBranch.NameWithoutRemote());
29-
29+
3030
if (matchingBranches == null)
3131
{
3232
log.Info($"No branch configuration found for branch {targetBranch.FriendlyName}, falling back to default configuration");
@@ -84,7 +84,7 @@ private BranchConfig InheritBranchConfiguration(Branch targetBranch, BranchConfi
8484
List<Branch> possibleParents;
8585
if (branchPoint == BranchCommit.Empty)
8686
{
87-
possibleParents = context.RepositoryMetadataProvider.GetBranchesContainingCommit(targetBranch.Tip, branchesToEvaluate, true)
87+
possibleParents = context.RepositoryMetadataProvider.GetBranchesContainingCommit(targetBranch.Tip, branchesToEvaluate, false)
8888
// It fails to inherit Increment branch configuration if more than 1 parent;
8989
// therefore no point to get more than 2 parents
9090
.Take(2)
@@ -93,11 +93,11 @@ private BranchConfig InheritBranchConfiguration(Branch targetBranch, BranchConfi
9393
else
9494
{
9595
var branches = context.RepositoryMetadataProvider
96-
.GetBranchesContainingCommit(branchPoint.Commit, branchesToEvaluate, true).ToList();
96+
.GetBranchesContainingCommit(branchPoint.Commit, branchesToEvaluate, false).ToList();
9797
if (branches.Count > 1)
9898
{
9999
var currentTipBranches = context.RepositoryMetadataProvider
100-
.GetBranchesContainingCommit(context.CurrentCommit, branchesToEvaluate, true).ToList();
100+
.GetBranchesContainingCommit(context.CurrentCommit, branchesToEvaluate, false).ToList();
101101
possibleParents = branches.Except(currentTipBranches).ToList();
102102
}
103103
else

src/GitVersionCore/GitRepoMetadataProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public IEnumerable<Branch> GetBranchesContainingCommit(Commit commit, IList<Bran
8181
// TODO: It looks wasteful looping through the branches twice. Can't these loops be merged somehow? @asbjornu
8282
foreach (var branch in branches)
8383
{
84-
if (branch.Tip != null && branch.Tip.Sha != commit.Sha || (onlyTrackedBranches && !branch.IsTracking))
84+
if (branch.Tip != null && branch.Tip.Sha != commit.Sha || ((onlyTrackedBranches && branch.IsTracking) || !onlyTrackedBranches))
8585
{
8686
continue;
8787
}
@@ -97,7 +97,7 @@ public IEnumerable<Branch> GetBranchesContainingCommit(Commit commit, IList<Bran
9797
}
9898

9999
log.Info($"No direct branches found, searching through {(onlyTrackedBranches ? "tracked" : "all")} branches.");
100-
foreach (var branch in branches.Where(b => onlyTrackedBranches && !b.IsTracking))
100+
foreach (var branch in branches.Where(b => (onlyTrackedBranches && b.IsTracking) || !onlyTrackedBranches))
101101
{
102102
log.Info($"Searching for commits reachable from '{branch.FriendlyName}'.");
103103

src/GitVersionCore/GitVersionContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ public class GitVersionContext
1414
{
1515
private readonly ILog log;
1616

17-
public GitVersionContext(IRepository repository, ILog log, string targetBranch, Config configuration, bool onlyEvaluateTrackedBranches = true, string commitId = null)
17+
public GitVersionContext(IRepository repository, ILog log, string targetBranch, Config configuration, bool onlyEvaluateTrackedBranches = false, string commitId = null)
1818
: this(repository, log, GetTargetBranch(repository, targetBranch), configuration, onlyEvaluateTrackedBranches, commitId)
1919
{
2020
}
2121

22-
public GitVersionContext(IRepository repository, ILog log, Branch currentBranch, Config configuration, bool onlyEvaluateTrackedBranches = true, string commitId = null)
22+
public GitVersionContext(IRepository repository, ILog log, Branch currentBranch, Config configuration, bool onlyEvaluateTrackedBranches = false, string commitId = null)
2323
{
2424
this.log = log;
2525
Repository = repository;

0 commit comments

Comments
 (0)