summaryrefslogtreecommitdiffstats
path: root/modules/repository
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2020-09-15 16:37:44 +0200
committerGitHub <noreply@github.com>2020-09-15 22:37:44 +0800
commit6c61f498ea6edb9260bc2b2b8db5bc3cb9214522 (patch)
tree9d1322d4ff85aec9d24f98f65d72c5a54cc1838d /modules/repository
parent3d0ad2885a25012ba08c42a4ed181dc22dd72770 (diff)
downloadgitea-6c61f498ea6edb9260bc2b2b8db5bc3cb9214522.tar.gz
gitea-6c61f498ea6edb9260bc2b2b8db5bc3cb9214522.zip
On Migration respect old DefaultBranch (#12843)
* On Migration respect old DefaultBranch * add DefaultBranch int test set Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'modules/repository')
-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)
+ }
}
}