Skip to content

Commit 7842a40

Browse files
committed
Added null guards in BranchConfigurationCalculatorBranchConfigurationCalculato.LookupBranchConfiguration()`.
1 parent 7a482c0 commit 7842a40

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/GitVersionCore/BranchConfigurationCalculator.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ namespace GitVersion
44
using System.Collections.Generic;
55
using System.Linq;
66
using System.Text.RegularExpressions;
7+
8+
using JetBrains.Annotations;
9+
710
using LibGit2Sharp;
811

912
public class BranchConfigurationCalculator
@@ -35,11 +38,22 @@ public static KeyValuePair<string, BranchConfig> GetBranchConfiguration(Commit c
3538
throw new Exception(string.Format(format, currentBranch.Name, string.Join(", ", matchingBranches.Select(b => b.Key))));
3639
}
3740

38-
static KeyValuePair<string, BranchConfig>[] LookupBranchConfiguration(Config config, Branch currentBranch)
41+
static KeyValuePair<string, BranchConfig>[] LookupBranchConfiguration([NotNull] Config config, [NotNull] Branch currentBranch)
3942
{
43+
if (config == null)
44+
{
45+
throw new ArgumentNullException("config");
46+
}
47+
48+
if (currentBranch == null)
49+
{
50+
throw new ArgumentNullException("currentBranch");
51+
}
52+
4053
return config.Branches.Where(b => Regex.IsMatch(currentBranch.Name, "^" + b.Key, RegexOptions.IgnoreCase)).ToArray();
4154
}
4255

56+
4357
static KeyValuePair<string, BranchConfig> InheritBranchConfiguration(bool onlyEvaluateTrackedBranches, IRepository repository, Commit currentCommit, Branch currentBranch, KeyValuePair<string, BranchConfig> keyValuePair, BranchConfig branchConfiguration, Config config, IList<Branch> excludedInheritBranches)
4458
{
4559
using (Logger.IndentLog("Attempting to inherit branch configuration from parent branch"))

0 commit comments

Comments
 (0)