diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2019-07-02 05:17:16 +0800 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2019-07-01 22:17:16 +0100 |
commit | e728b5581291d6d9a62fcd8ab2c3b2e6c89b7138 (patch) | |
tree | 5ea593bc5394e271254746464fd1da8338dc3499 /models | |
parent | 9fdd199cca780a13b44a667ee862b1ec3ff37958 (diff) | |
download | gitea-e728b5581291d6d9a62fcd8ab2c3b2e6c89b7138.tar.gz gitea-e728b5581291d6d9a62fcd8ab2c3b2e6c89b7138.zip |
Fix bug conflict between SyncReleasesWithTags and InsertReleases (#7337)
* fix bug conflict between SyncReleasesWithTags and InsertReleases
* fix tests
* fix fmt
Diffstat (limited to 'models')
-rw-r--r-- | models/release_test.go | 13 | ||||
-rw-r--r-- | models/repo.go | 15 |
2 files changed, 15 insertions, 13 deletions
diff --git a/models/release_test.go b/models/release_test.go index f3f61240ea..83c3fe2f77 100644 --- a/models/release_test.go +++ b/models/release_test.go @@ -102,12 +102,13 @@ func TestRelease_MirrorDelete(t *testing.T) { repo := AssertExistsAndLoadBean(t, &Repository{ID: 1}).(*Repository) repoPath := RepoPath(user.Name, repo.Name) migrationOptions := MigrateRepoOptions{ - Name: "test_mirror", - Description: "Test mirror", - IsPrivate: false, - IsMirror: true, - RemoteAddr: repoPath, - Wiki: true, + Name: "test_mirror", + Description: "Test mirror", + IsPrivate: false, + IsMirror: true, + RemoteAddr: repoPath, + Wiki: true, + SyncReleasesWithTags: true, } mirror, err := MigrateRepository(user, user, migrationOptions) assert.NoError(t, err) diff --git a/models/repo.go b/models/repo.go index 1b4ff1f186..59ce18fa88 100644 --- a/models/repo.go +++ b/models/repo.go @@ -845,12 +845,13 @@ func (repo *Repository) CloneLink() (cl *CloneLink) { // MigrateRepoOptions contains the repository migrate options type MigrateRepoOptions struct { - Name string - Description string - IsPrivate bool - IsMirror bool - RemoteAddr string - Wiki bool // include wiki repository + Name string + Description string + IsPrivate bool + IsMirror bool + RemoteAddr string + Wiki bool // include wiki repository + SyncReleasesWithTags bool // sync releases from tags } /* @@ -942,7 +943,7 @@ func MigrateRepository(doer, u *User, opts MigrateRepoOptions) (*Repository, err return repo, fmt.Errorf("git.IsEmpty: %v", err) } - if !repo.IsEmpty { + if opts.SyncReleasesWithTags && !repo.IsEmpty { // Try to get HEAD branch and set it as default branch. headBranch, err := gitRepo.GetHEADBranch() if err != nil { |