feat: add functions to convert a release
This commit is contained in:
parent
bf9e062644
commit
e33587b406
|
@ -435,3 +435,48 @@ func translatePrAction(action structs.HookIssueAction, prefix bool) string {
|
|||
|
||||
return translatedAction
|
||||
}
|
||||
|
||||
func convertRelease(release *gitea.Release) *github.RepositoryRelease {
|
||||
if release == nil {
|
||||
return &github.RepositoryRelease{}
|
||||
}
|
||||
return &github.RepositoryRelease{
|
||||
ID: int64Ptr(release.ID),
|
||||
TagName: stringPtr(release.TagName),
|
||||
TargetCommitish: stringPtr(release.Target),
|
||||
Name: stringPtr(release.Title),
|
||||
Body: stringPtr(release.Note),
|
||||
Draft: boolPtr(release.IsDraft),
|
||||
Prerelease: boolPtr(release.IsPrerelease),
|
||||
CreatedAt: timePtr(release.CreatedAt),
|
||||
PublishedAt: timePtr(release.PublishedAt),
|
||||
Assets: convertReleaseAttachments(release.Attachments),
|
||||
URL: stringPtr(release.URL),
|
||||
ZipballURL: stringPtr(release.ZipURL),
|
||||
TarballURL: stringPtr(release.TarURL),
|
||||
HTMLURL: stringPtr(release.HTMLURL),
|
||||
}
|
||||
}
|
||||
|
||||
func convertReleaseAttachments(attachments []*gitea.Attachment) []*github.ReleaseAsset {
|
||||
if attachments == nil {
|
||||
return make([]*github.ReleaseAsset, 0)
|
||||
}
|
||||
var ghAttachments []*github.ReleaseAsset
|
||||
for _, attachment := range attachments {
|
||||
ghAttachments = append(ghAttachments, convertReleaseAttachment(attachment))
|
||||
}
|
||||
return ghAttachments
|
||||
}
|
||||
func convertReleaseAttachment(attachment *gitea.Attachment) *github.ReleaseAsset {
|
||||
if attachment == nil {
|
||||
return &github.ReleaseAsset{}
|
||||
}
|
||||
return &github.ReleaseAsset{
|
||||
ID: int64Ptr(attachment.ID),
|
||||
Name: stringPtr(attachment.Name),
|
||||
Size: intPtr(int(attachment.Size)),
|
||||
DownloadCount: intPtr(int(attachment.DownloadCount)),
|
||||
BrowserDownloadURL: stringPtr(attachment.DownloadURL),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue