aboutsummaryrefslogtreecommitdiffstats
path: root/services/mirror/mirror.go
diff options
context:
space:
mode:
authorChester Liu <skyline75489@outlook.com>2020-12-30 23:46:26 +0800
committerGitHub <noreply@github.com>2020-12-30 15:46:26 +0000
commit632800eda7108e5e8d90dd9e3e985da3deecf365 (patch)
treeba1c53f6efe0ec373ea311fec8895a278b2f4bcd /services/mirror/mirror.go
parentc074e462926f939db1b63b6a40df98da3fb33b6b (diff)
downloadgitea-632800eda7108e5e8d90dd9e3e985da3deecf365.tar.gz
gitea-632800eda7108e5e8d90dd9e3e985da3deecf365.zip
Check for 'main' as potential default branch name (#14193)
Diffstat (limited to 'services/mirror/mirror.go')
-rw-r--r--services/mirror/mirror.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/services/mirror/mirror.go b/services/mirror/mirror.go
index a2acb6f363..328e23ad2f 100644
--- a/services/mirror/mirror.go
+++ b/services/mirror/mirror.go
@@ -521,6 +521,7 @@ func checkAndUpdateEmptyRepository(m *models.Mirror, gitRepo *git.Repository, re
hasDefault := false
hasMaster := false
+ hasMain := false
defaultBranchName := m.Repo.DefaultBranch
if len(defaultBranchName) == 0 {
defaultBranchName = setting.Repository.DefaultBranch
@@ -540,6 +541,7 @@ func checkAndUpdateEmptyRepository(m *models.Mirror, gitRepo *git.Repository, re
hasDefault = hasDefault || name == defaultBranchName
hasMaster = hasMaster || name == "master"
+ hasMain = hasMain || name == "main"
}
if len(firstName) > 0 {
@@ -547,6 +549,8 @@ func checkAndUpdateEmptyRepository(m *models.Mirror, gitRepo *git.Repository, re
m.Repo.DefaultBranch = defaultBranchName
} else if hasMaster {
m.Repo.DefaultBranch = "master"
+ } else if hasMain {
+ m.Repo.DefaultBranch = "main"
} else {
m.Repo.DefaultBranch = firstName
}