summaryrefslogtreecommitdiffstats
path: root/modules/repository/init.go
diff options
context:
space:
mode:
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 {