Skip to content

Commit 7116ada

Browse files
committed
GH-2587 - fix source branch for master
1 parent 02cb280 commit 7116ada

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/GitVersion.Core/Configuration/ConfigurationBuilder.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ private static void ApplyBranchOverrides(Config targetConfig, Config overrideCon
9797
}
9898

9999
branchConfig.MergeTo(target);
100+
if (target.SourceBranches != null && target.SourceBranches.Contains(Config.MasterBranchKey))
101+
{
102+
target.SourceBranches.Remove(Config.MasterBranchKey);
103+
target.SourceBranches.Add(Config.MainBranchKey);
104+
}
100105
newBranches[branchName] = target;
101106
}
102107

@@ -155,20 +160,22 @@ private static void ValidateConfiguration(Config config)
155160
foreach (var (name, branchConfig) in config.Branches)
156161
{
157162
var regex = branchConfig.Regex;
163+
var helpUrl = $"{System.Environment.NewLine}See https://gitversion.net/docs/configuration for more info";
164+
158165
if (regex == null)
159166
{
160-
throw new ConfigurationException($"Branch configuration '{name}' is missing required configuration 'regex'{System.Environment.NewLine}" + "See https://gitversion.net/docs/configuration for more info");
167+
throw new ConfigurationException($"Branch configuration '{name}' is missing required configuration 'regex'{helpUrl}");
161168
}
162169

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

169176
var missingSourceBranches = sourceBranches.Where(sb => !config.Branches.ContainsKey(sb)).ToArray();
170177
if (missingSourceBranches.Any())
171-
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");
178+
throw new ConfigurationException($"Branch configuration '{name}' defines these 'source-branches' that are not configured: '[{string.Join(",", missingSourceBranches)}]'{helpUrl}");
172179
}
173180
}
174181

0 commit comments

Comments
 (0)