diff options
author | Unknwon <u@gogs.io> | 2015-07-05 18:34:16 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2015-07-05 18:34:16 +0800 |
commit | c6531c4882123e412a288422d91dcd70ff913d33 (patch) | |
tree | 1df8cd18326e3ef3d12fa28c9a47569f56ea2bd0 /models/repo.go | |
parent | 1564b77cf562fe61786acd07a671ae5140d8eeb6 (diff) | |
download | gitea-c6531c4882123e412a288422d91dcd70ff913d33.tar.gz gitea-c6531c4882123e412a288422d91dcd70ff913d33.zip |
check master as default branch when migrate
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 9 |
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) } |