* Fix migrate release from github * Fix bug
This commit is contained in:
parent
8ff542c1a2
commit
928b603d19
1 changed files with 12 additions and 9 deletions
|
@ -7,6 +7,7 @@ package migrations
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
@ -246,7 +247,6 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
|
|||
LowerTagName: strings.ToLower(release.TagName),
|
||||
Target: release.TargetCommitish,
|
||||
Title: release.Name,
|
||||
Sha1: release.TargetCommitish,
|
||||
Note: release.Body,
|
||||
IsDraft: release.Draft,
|
||||
IsPrerelease: release.Prerelease,
|
||||
|
@ -275,15 +275,18 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
|
|||
rel.OriginalAuthorID = release.PublisherID
|
||||
}
|
||||
|
||||
// calc NumCommits if no draft
|
||||
if !release.Draft {
|
||||
// calc NumCommits if possible
|
||||
if rel.TagName != "" {
|
||||
commit, err := g.gitRepo.GetTagCommit(rel.TagName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetTagCommit[%v]: %v", rel.TagName, err)
|
||||
}
|
||||
rel.NumCommits, err = commit.CommitsCount()
|
||||
if err != nil {
|
||||
return fmt.Errorf("CommitsCount: %v", err)
|
||||
if !errors.Is(err, git.ErrNotExist{}) {
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetTagCommit[%v]: %v", rel.TagName, err)
|
||||
}
|
||||
rel.Sha1 = commit.ID.String()
|
||||
rel.NumCommits, err = commit.CommitsCount()
|
||||
if err != nil {
|
||||
return fmt.Errorf("CommitsCount: %v", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue