Skip to content

Commit 9a703cf

Browse files
DanielRoseJakeGinnivan
authored andcommitted
Break out of infinite loops when inheriting.
1 parent f185080 commit 9a703cf

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/GitVersionCore/BranchConfigurationCalculator.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ static BranchConfig InheritBranchConfiguration(bool onlyEvaluateTrackedBranches,
148148
var branchName = chosenBranch.FriendlyName;
149149
Logger.WriteWarning(errorMessage + Environment.NewLine + Environment.NewLine + "Falling back to " + branchName + " branch config");
150150

151+
// To prevent infinite loops, make sure that a new branch was chosen.
152+
if (LibGitExtensions.IsSameBranch(currentBranch, chosenBranch))
153+
{
154+
Logger.WriteWarning("Fallback branch wants to inherit Increment branch configuration from itself. Using patch increment instead.");
155+
return new BranchConfig(branchConfiguration)
156+
{
157+
Increment = IncrementStrategy.Patch
158+
};
159+
}
160+
151161
var inheritingBranchConfig = GetBranchConfiguration(currentCommit, repository, onlyEvaluateTrackedBranches, config, chosenBranch, excludedInheritBranches);
152162
return new BranchConfig(branchConfiguration)
153163
{

0 commit comments

Comments
 (0)