Skip to content

Commit b4ec263

Browse files
committed
Added some logging
1 parent 65d0c0c commit b4ec263

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

GitVersionCore/GitVersionContext.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ KeyValuePair<string, BranchConfig> GetBranchConfiguration(Branch currentBranch)
9292

9393
KeyValuePair<string, BranchConfig> InheritBranchConfiguration(Branch currentBranch, KeyValuePair<string, BranchConfig> keyValuePair, BranchConfig branchConfiguration)
9494
{
95+
Logger.WriteInfo("Attempting to inherit branch configuration from parent branch");
9596
var excludedBranches = new Branch[0];
9697
// Check if we are a merge commit. If so likely we are a pull request
9798
var parentCount = CurrentCommit.Parents.Count();
@@ -112,6 +113,8 @@ KeyValuePair<string, BranchConfig> InheritBranchConfiguration(Branch currentBran
112113
{
113114
currentBranch = Repository.Branches.SingleOrDefault(b => !b.IsRemote && b.Tip == parents[0]) ?? currentBranch;
114115
}
116+
117+
Logger.WriteInfo("HEAD is merge commit, this is likely a pull request using " + currentBranch.Name + " as base");
115118
}
116119

117120
var branchPoint = currentBranch.FindCommitBranchWasBranchedFrom(Repository, OnlyEvaluateTrackedBranches, excludedBranches);
@@ -133,6 +136,8 @@ KeyValuePair<string, BranchConfig> InheritBranchConfiguration(Branch currentBran
133136
.ToList();
134137
}
135138

139+
Logger.WriteInfo("Found possible parent branches: " + string.Join(", ", possibleParents.Select(p => p.Name)));
140+
136141
// If it comes down to master and something, master is always first so we pick other branch
137142
if (possibleParents.Count == 2 && possibleParents.Any(p => p.Name == "master"))
138143
{
@@ -149,7 +154,10 @@ KeyValuePair<string, BranchConfig> InheritBranchConfiguration(Branch currentBran
149154
});
150155
}
151156

152-
throw new Exception("Failed to inherit Increment branch configuration");
157+
if (possibleParents.Count == 0)
158+
throw new Exception("Failed to inherit Increment branch configuration, no branches found");
159+
160+
throw new Exception("Failed to inherit Increment branch configuration, ended up with: " + string.Join(", ", possibleParents.Select(p => p.Name)));
153161
}
154162

155163
static IEnumerable<Branch> ListBranchesContaininingCommit(IRepository repo, string commitSha, Branch[] excludedBranches)

0 commit comments

Comments
 (0)