Skip to content

Commit ddd4e81

Browse files
committed
Throw exception if the current branch can't be found, instead of passing on null, causing ArgumentNullException or worse; NullReferenceException.
1 parent 7842a40 commit ddd4e81

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/GitVersionCore/BranchConfigurationCalculator.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,14 @@ static KeyValuePair<string, BranchConfig> InheritBranchConfiguration(bool onlyEv
122122
var branchName = developBranch != null ? developBranch.Name : "master";
123123

124124
Logger.WriteWarning(errorMessage + Environment.NewLine + Environment.NewLine + "Falling back to " + branchName + " branch config");
125-
var value = GetBranchConfiguration(currentCommit, repository, onlyEvaluateTrackedBranches, config, repository.Branches[branchName]).Value;
125+
currentBranch = repository.Branches[branchName];
126+
127+
if (currentBranch == null)
128+
{
129+
throw new InvalidOperationException(String.Format("Could not find the branch '{0}'.", branchName));
130+
}
131+
132+
var value = GetBranchConfiguration(currentCommit, repository, onlyEvaluateTrackedBranches, config, currentBranch).Value;
126133
return new KeyValuePair<string, BranchConfig>(
127134
keyValuePair.Key,
128135
new BranchConfig(branchConfiguration)

0 commit comments

Comments
 (0)