Skip to content

Commit d68122f

Browse files
committed
Fixed BranchCreatedAfterFastForwardMergeShouldInheritCorrectly test
1 parent 00f60a4 commit d68122f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

GitVersionCore/BranchConfigurationCalculator.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class BranchConfigurationCalculator
1010
{
1111
public static KeyValuePair<string, BranchConfig> GetBranchConfiguration(Commit currentCommit, IRepository repository, bool onlyEvaluateTrackedBranches, Config config, Branch currentBranch, IList<Branch> excludedInheritBranches = null)
1212
{
13-
var matchingBranches = config.Branches.Where(b => Regex.IsMatch(currentBranch.Name, "^" + b.Key, RegexOptions.IgnoreCase)).ToArray();
13+
var matchingBranches = LookupBranchConfiguration(config, currentBranch);
1414

1515
if (matchingBranches.Length == 0)
1616
{
@@ -33,6 +33,11 @@ public static KeyValuePair<string, BranchConfig> GetBranchConfiguration(Commit c
3333
throw new Exception(string.Format(format, currentBranch.Name, string.Join(", ", matchingBranches.Select(b => b.Key))));
3434
}
3535

36+
static KeyValuePair<string, BranchConfig>[] LookupBranchConfiguration(Config config, Branch currentBranch)
37+
{
38+
return config.Branches.Where(b => Regex.IsMatch(currentBranch.Name, "^" + b.Key, RegexOptions.IgnoreCase)).ToArray();
39+
}
40+
3641
static KeyValuePair<string, BranchConfig> InheritBranchConfiguration(bool onlyEvaluateTrackedBranches, IRepository repository, Commit currentCommit, Branch currentBranch, KeyValuePair<string, BranchConfig> keyValuePair, BranchConfig branchConfiguration, Config config, IList<Branch> excludedInheritBranches)
3742
{
3843
Logger.WriteInfo("Attempting to inherit branch configuration from parent branch");
@@ -69,7 +74,11 @@ static KeyValuePair<string, BranchConfig> InheritBranchConfiguration(bool onlyEv
6974
}
7075
if (excludedInheritBranches == null)
7176
{
72-
excludedInheritBranches = new List<Branch>();
77+
excludedInheritBranches = repository.Branches.Where(b =>
78+
{
79+
var branchConfig = LookupBranchConfiguration(config, b);
80+
return branchConfig.Length == 1 && branchConfig[0].Value.Increment == IncrementStrategy.Inherit;
81+
}).ToList();
7382
}
7483
excludedBranches.ToList().ForEach(excludedInheritBranches.Add);
7584

0 commit comments

Comments
 (0)