Skip to content

Commit 058491d

Browse files
asbjornuarturcic
authored andcommitted
Add fallback for main and develop branch regex
Add fallback for `null` in the configuration for the for `main` and `develop` branch regular expressions.
1 parent 5eacf53 commit 058491d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/GitVersion.Core/Configuration/BranchConfigurationCalculator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ private IBranch[] CalculateWhenMultipleParents(ICommit currentCommit, ref IBranc
226226
private static BranchConfig? ChooseMainOrDevelopIncrementStrategyIfTheChosenBranchIsOneOfThem(IBranch chosenBranch, BranchConfig branchConfiguration, Config config)
227227
{
228228
BranchConfig? mainOrDevelopConfig = null;
229-
var developBranchRegex = config.Branches[Config.DevelopBranchKey]?.Regex;
230-
var mainBranchRegex = config.Branches[Config.MainBranchKey]?.Regex;
229+
var developBranchRegex = config.Branches[Config.DevelopBranchKey]?.Regex ?? Config.DevelopBranchRegex;
230+
var mainBranchRegex = config.Branches[Config.MainBranchKey]?.Regex ?? Config.MainBranchRegex;
231231
if (Regex.IsMatch(chosenBranch.Name.Friendly, developBranchRegex, RegexOptions.IgnoreCase))
232232
{
233233
// Normally we would not expect this to happen but for safety we add a check

0 commit comments

Comments
 (0)