Skip to content

Commit 2c2019f

Browse files
committed
Filter remote branches to fix PRs
1 parent a611c65 commit 2c2019f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

GitVersionCore/GitVersionContext.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ KeyValuePair<string, BranchConfig> InheritBranchConfiguration(Branch currentBran
127127
if (parentCount == 2)
128128
{
129129
var parents = CurrentCommit.Parents.ToArray();
130-
var branch = Repository.Branches.SingleOrDefault(b => b.Tip == parents[1]) ;
130+
var branch = Repository.Branches.SingleOrDefault(b => !b.IsRemote && b.Tip == parents[1]) ;
131131
if (branch != null)
132132
{
133133
excludedBranches = new[]
@@ -139,7 +139,7 @@ KeyValuePair<string, BranchConfig> InheritBranchConfiguration(Branch currentBran
139139
}
140140
else
141141
{
142-
currentBranch = Repository.Branches.SingleOrDefault(b => b.Tip == parents[0]) ?? currentBranch;
142+
currentBranch = Repository.Branches.SingleOrDefault(b => !b.IsRemote && b.Tip == parents[0]) ?? currentBranch;
143143
}
144144
}
145145

GitVersionCore/LibGitExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static Branch FindBranch(this IRepository repository, string branchName)
2626

2727
public static Commit FindCommitBranchWasBranchedFrom(this Branch branch, IRepository repository, params Branch[] excludedBranches)
2828
{
29-
var tips = repository.Branches.Except(excludedBranches).Where(b => b != branch).Select(b => b.Tip).ToList();
29+
var tips = repository.Branches.Except(excludedBranches).Where(b => b != branch && !b.IsRemote).Select(b => b.Tip).ToList();
3030
return branch.Commits.FirstOrDefault(c => tips.Contains(c) || c.Parents.Count() > 1) ?? branch.Tip;
3131
}
3232

0 commit comments

Comments
 (0)