Skip to content

Commit

Permalink
GH-2587 - fix source branch for master
Browse files Browse the repository at this point in the history
  • Loading branch information
arturcic committed Feb 8, 2021
1 parent 02cb280 commit 7116ada
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/GitVersion.Core/Configuration/ConfigurationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ private static void ApplyBranchOverrides(Config targetConfig, Config overrideCon
}

branchConfig.MergeTo(target);
if (target.SourceBranches != null && target.SourceBranches.Contains(Config.MasterBranchKey))
{
target.SourceBranches.Remove(Config.MasterBranchKey);
target.SourceBranches.Add(Config.MainBranchKey);
}
newBranches[branchName] = target;
}

Expand Down Expand Up @@ -155,20 +160,22 @@ private static void ValidateConfiguration(Config config)
foreach (var (name, branchConfig) in config.Branches)
{
var regex = branchConfig.Regex;
var helpUrl = $"{System.Environment.NewLine}See https://gitversion.net/docs/configuration for more info";

if (regex == null)
{
throw new ConfigurationException($"Branch configuration '{name}' is missing required configuration 'regex'{System.Environment.NewLine}" + "See https://gitversion.net/docs/configuration for more info");
throw new ConfigurationException($"Branch configuration '{name}' is missing required configuration 'regex'{helpUrl}");
}

var sourceBranches = branchConfig.SourceBranches;
if (sourceBranches == null)
{
throw new ConfigurationException($"Branch configuration '{name}' is missing required configuration 'source-branches'{System.Environment.NewLine}" + "See https://gitversion.net/docs/configuration for more info");
throw new ConfigurationException($"Branch configuration '{name}' is missing required configuration 'source-branches'{helpUrl}");
}

var missingSourceBranches = sourceBranches.Where(sb => !config.Branches.ContainsKey(sb)).ToArray();
if (missingSourceBranches.Any())
throw new ConfigurationException($"Branch configuration '{name}' defines these 'source-branches' that are not configured: '[{string.Join(",", missingSourceBranches)}]'{System.Environment.NewLine}" + "See https://gitversion.net/docs/configuration for more info");
throw new ConfigurationException($"Branch configuration '{name}' defines these 'source-branches' that are not configured: '[{string.Join(",", missingSourceBranches)}]'{helpUrl}");
}
}

Expand Down

0 comments on commit 7116ada

Please sign in to comment.