Skip to content

Commit 719f269

Browse files
committed
Fall back to master if main is missing
Fall back to the `master` configuration regex if `main` is missing from the configuration. If none of them are found, do a verbatim string search for branches named `main` with fallback to `master`.
1 parent 0985daa commit 719f269

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/GitVersion.Core/Core/RepositoryStore.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,12 @@ public IBranch GetTargetBranch(string? targetBranchName)
128128

129129
public IBranch? FindMainBranch(Config configuration)
130130
{
131-
var mainBranchRegex = configuration.Branches[Config.MainBranchKey]?.Regex;
131+
var mainBranchRegex = configuration.Branches[Config.MainBranchKey]?.Regex
132+
?? configuration.Branches[Config.MasterBranchKey]?.Regex;
133+
132134
if (mainBranchRegex == null)
133135
{
134-
return null;
136+
return FindBranch(Config.MainBranchKey) ?? FindBranch(Config.MasterBranchKey);
135137
}
136138

137139
return this.repository.Branches.FirstOrDefault(b =>

0 commit comments

Comments
 (0)