summaryrefslogtreecommitdiffstats
path: root/modules/repository/repo.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/repository/repo.go')
-rw-r--r--modules/repository/repo.go24
1 files changed, 14 insertions, 10 deletions
diff --git a/modules/repository/repo.go b/modules/repository/repo.go
index 36e9ed49c1..b18dfddd2e 100644
--- a/modules/repository/repo.go
+++ b/modules/repository/repo.go
@@ -102,18 +102,22 @@ func MigrateRepositoryGitData(doer, u *models.User, repo *models.Repository, opt
return repo, fmt.Errorf("git.IsEmpty: %v", err)
}
- if !opts.Releases && !repo.IsEmpty {
- // Try to get HEAD branch and set it as default branch.
- headBranch, err := gitRepo.GetHEADBranch()
- if err != nil {
- return repo, fmt.Errorf("GetHEADBranch: %v", err)
- }
- if headBranch != nil {
- repo.DefaultBranch = headBranch.Name
+ if !repo.IsEmpty {
+ if len(repo.DefaultBranch) == 0 {
+ // Try to get HEAD branch and set it as default branch.
+ headBranch, err := gitRepo.GetHEADBranch()
+ if err != nil {
+ return repo, fmt.Errorf("GetHEADBranch: %v", err)
+ }
+ if headBranch != nil {
+ repo.DefaultBranch = headBranch.Name
+ }
}
- if err = SyncReleasesWithTags(repo, gitRepo); err != nil {
- log.Error("Failed to synchronize tags to releases for repository: %v", err)
+ if !opts.Releases {
+ if err = SyncReleasesWithTags(repo, gitRepo); err != nil {
+ log.Error("Failed to synchronize tags to releases for repository: %v", err)
+ }
}
}