forked from gitea/gitea
* Fix migrate release from github * Fix bug
This commit is contained in:
parent
8ff542c1a2
commit
928b603d19
|
@ -7,6 +7,7 @@ package migrations
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -246,7 +247,6 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
|
||||||
LowerTagName: strings.ToLower(release.TagName),
|
LowerTagName: strings.ToLower(release.TagName),
|
||||||
Target: release.TargetCommitish,
|
Target: release.TargetCommitish,
|
||||||
Title: release.Name,
|
Title: release.Name,
|
||||||
Sha1: release.TargetCommitish,
|
|
||||||
Note: release.Body,
|
Note: release.Body,
|
||||||
IsDraft: release.Draft,
|
IsDraft: release.Draft,
|
||||||
IsPrerelease: release.Prerelease,
|
IsPrerelease: release.Prerelease,
|
||||||
|
@ -275,17 +275,20 @@ func (g *GiteaLocalUploader) CreateReleases(releases ...*base.Release) error {
|
||||||
rel.OriginalAuthorID = release.PublisherID
|
rel.OriginalAuthorID = release.PublisherID
|
||||||
}
|
}
|
||||||
|
|
||||||
// calc NumCommits if no draft
|
// calc NumCommits if possible
|
||||||
if !release.Draft {
|
if rel.TagName != "" {
|
||||||
commit, err := g.gitRepo.GetTagCommit(rel.TagName)
|
commit, err := g.gitRepo.GetTagCommit(rel.TagName)
|
||||||
|
if !errors.Is(err, git.ErrNotExist{}) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("GetTagCommit[%v]: %v", rel.TagName, err)
|
return fmt.Errorf("GetTagCommit[%v]: %v", rel.TagName, err)
|
||||||
}
|
}
|
||||||
|
rel.Sha1 = commit.ID.String()
|
||||||
rel.NumCommits, err = commit.CommitsCount()
|
rel.NumCommits, err = commit.CommitsCount()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("CommitsCount: %v", err)
|
return fmt.Errorf("CommitsCount: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, asset := range release.Assets {
|
for _, asset := range release.Assets {
|
||||||
if asset.Created.IsZero() {
|
if asset.Created.IsZero() {
|
||||||
|
|
Loading…
Reference in New Issue