summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/repo.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/models/repo.go b/models/repo.go
index f144be5a3f..ca118d99a7 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -380,6 +380,15 @@ func MigrateRepository(u *User, name, desc string, private, mirror bool, url str
return repo, fmt.Errorf("create update hook: %v", err)
}
+ // Check if repository has master branch, if so set it to default branch.
+ gitRepo, err := git.OpenRepository(repoPath)
+ if err != nil {
+ return repo, fmt.Errorf("open git repository: %v", err)
+ }
+ if gitRepo.IsBranchExist("master") {
+ repo.DefaultBranch = "master"
+ }
+
return repo, UpdateRepository(repo, false)
}