aboutsummaryrefslogtreecommitdiff
path: root/models/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/models/repo.go b/models/repo.go
index f144be5a..4ee5c382 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)
}
@@ -1049,7 +1058,7 @@ func MirrorUpdate() {
repoPath := filepath.Join(setting.RepoRootPath, m.RepoName+".git")
if _, stderr, err := process.ExecDir(10*time.Minute,
repoPath, fmt.Sprintf("MirrorUpdate: %s", repoPath),
- "git", "remote", "update"); err != nil {
+ "git", "remote", "update", "--prune"); err != nil {
desc := fmt.Sprintf("Fail to update mirror repository(%s): %s", repoPath, stderr)
log.Error(4, desc)
if err = CreateRepositoryNotice(desc); err != nil {