aboutsummaryrefslogtreecommitdiffstats
path: root/modules/migrations/gitea_uploader.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-05-16 00:37:17 +0200
committerGitHub <noreply@github.com>2021-05-15 18:37:17 -0400
commite0c93fed05f5863ebef2ff584734709c79d926f2 (patch)
tree64911d64b4f6049c88f69e728812de13c7f49033 /modules/migrations/gitea_uploader.go
parent8e32eeb5deed2da2dc2a648f62cba2613b566f71 (diff)
downloadgitea-e0c93fed05f5863ebef2ff584734709c79d926f2.tar.gz
gitea-e0c93fed05f5863ebef2ff584734709c79d926f2.zip
GitHub: migrate draft releases too (#15884)
* GitHub: migrate draft releases too * refactor
Diffstat (limited to 'modules/migrations/gitea_uploader.go')
-rw-r--r--modules/migrations/gitea_uploader.go21
1 files changed, 12 insertions, 9 deletions
diff --git a/modules/migrations/gitea_uploader.go b/modules/migrations/gitea_uploader.go
index 29118fd51b..8b865d7971 100644
--- a/modules/migrations/gitea_uploader.go
+++ b/modules/migrations/gitea_uploader.go
@@ -250,14 +250,16 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
rel.OriginalAuthorID = release.PublisherID
}
- // calc NumCommits
- commit, err := g.gitRepo.GetCommit(rel.TagName)
- if err != nil {
- return fmt.Errorf("GetCommit: %v", err)
- }
- rel.NumCommits, err = commit.CommitsCount()
- if err != nil {
- return fmt.Errorf("CommitsCount: %v", err)
+ // calc NumCommits if no draft
+ if !release.Draft {
+ commit, err := g.gitRepo.GetCommit(rel.TagName)
+ if err != nil {
+ return fmt.Errorf("GetCommit: %v", err)
+ }
+ rel.NumCommits, err = commit.CommitsCount()
+ if err != nil {
+ return fmt.Errorf("CommitsCount: %v", err)
+ }
}
for _, asset := range release.Assets {
@@ -270,9 +272,10 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
}
// download attachment
- err = func() error {
+ err := func() error {
// asset.DownloadURL maybe a local file
var rc io.ReadCloser
+ var err error
if asset.DownloadURL == nil {
rc, err = asset.DownloadFunc()
if err != nil {