Skip to content

Commit

Permalink
Fall back to master if main is missing
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
asbjornu committed Apr 13, 2022
1 parent 0985daa commit 719f269
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/GitVersion.Core/Core/RepositoryStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,12 @@ public IBranch GetTargetBranch(string? targetBranchName)

public IBranch? FindMainBranch(Config configuration)
{
var mainBranchRegex = configuration.Branches[Config.MainBranchKey]?.Regex;
var mainBranchRegex = configuration.Branches[Config.MainBranchKey]?.Regex
?? configuration.Branches[Config.MasterBranchKey]?.Regex;

if (mainBranchRegex == null)
{
return null;
return FindBranch(Config.MainBranchKey) ?? FindBranch(Config.MasterBranchKey);
}

return this.repository.Branches.FirstOrDefault(b =>
Expand Down

0 comments on commit 719f269

Please sign in to comment.