mirror of
https://gitea.com/jolheiser/sip
synced 2024-11-22 11:41:59 +01:00
0bbe2e35ff
Add attachment removal and change message Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: jolheiser <john.olheiser@gmail.com> Reviewed-on: https://gitea.com/jolheiser/sip/pulls/36
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package sdk
|
|
|
|
import (
|
|
"code.gitea.io/sdk/gitea"
|
|
)
|
|
|
|
// GetReleases returns all matching Releases from a Gitea instance
|
|
func GetReleases(client *gitea.Client, owner, repo string, opts gitea.ListReleasesOptions) ([]*gitea.Release, error) {
|
|
releases := make([]*gitea.Release, 0)
|
|
p := 1
|
|
for {
|
|
opts.Page = p
|
|
list, _, err := client.ListReleases(owner, repo, opts)
|
|
if err != nil {
|
|
return releases, err
|
|
}
|
|
p++
|
|
releases = append(releases, list...)
|
|
|
|
if len(list) == 0 {
|
|
break
|
|
}
|
|
}
|
|
return releases, nil
|
|
}
|
|
|
|
// GetReleaseAttachments returns all attachments from a release
|
|
func GetReleaseAttachments(client *gitea.Client, owner, repo string, releaseID int64, opts gitea.ListReleaseAttachmentsOptions) ([]*gitea.Attachment, error) {
|
|
attachments := make([]*gitea.Attachment, 0)
|
|
p := 1
|
|
for {
|
|
opts.Page = p
|
|
list, _, err := client.ListReleaseAttachments(owner, repo, releaseID, opts)
|
|
if err != nil {
|
|
return attachments, err
|
|
}
|
|
p++
|
|
attachments = append(attachments, list...)
|
|
|
|
// FIXME Seems paging doesn't want to work with release attachments
|
|
if len(list) == 0 || len(list) < 50 {
|
|
break
|
|
}
|
|
}
|
|
return attachments, nil
|
|
}
|