Skip to content

Commit ed46aa2

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 06f3175 commit ed46aa2

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
@@ -218,10 +218,12 @@ public IBranch GetTargetBranch(string? targetBranchName)
218218

219219
public IBranch? FindMainBranch(Config configuration)
220220
{
221-
var mainBranchRegex = configuration.Branches[Config.MainBranchKey]?.Regex;
221+
var mainBranchRegex = configuration.Branches[Config.MainBranchKey]?.Regex
222+
?? configuration.Branches[Config.MasterBranchKey]?.Regex;
223+
222224
if (mainBranchRegex == null)
223225
{
224-
return null;
226+
return FindBranch(Config.MainBranchKey) ?? FindBranch(Config.MasterBranchKey);
225227
}
226228

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

0 commit comments

Comments
 (0)