summaryrefslogtreecommitdiffstats
path: root/modules/repository/init.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 /modules/repository/init.go
parentc074e462926f939db1b63b6a40df98da3fb33b6b (diff)
downloadgitea-632800eda7108e5e8d90dd9e3e985da3deecf365.tar.gz
gitea-632800eda7108e5e8d90dd9e3e985da3deecf365.zip
Check for 'main' as potential default branch name (#14193)
Diffstat (limited to 'modules/repository/init.go')
-rw-r--r--modules/repository/init.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/repository/init.go b/modules/repository/init.go
index 16012864b1..a100456e77 100644
--- a/modules/repository/init.go
+++ b/modules/repository/init.go
@@ -243,6 +243,7 @@ func adoptRepository(ctx models.DBContext, repoPath string, u *models.User, repo
found := false
hasDefault := false
hasMaster := false
+ hasMain := false
for _, branch := range branches {
if branch == repo.DefaultBranch {
found = true
@@ -251,6 +252,8 @@ func adoptRepository(ctx models.DBContext, repoPath string, u *models.User, repo
hasDefault = true
} else if branch == "master" {
hasMaster = true
+ } else if branch == "main" {
+ hasMain = true
}
}
if !found {
@@ -258,6 +261,8 @@ func adoptRepository(ctx models.DBContext, repoPath string, u *models.User, repo
repo.DefaultBranch = setting.Repository.DefaultBranch
} else if hasMaster {
repo.DefaultBranch = "master"
+ } else if hasMain {
+ repo.DefaultBranch = "main"
} else if len(branches) > 0 {
repo.DefaultBranch = branches[0]
} else {