@@ -27,7 +27,6 @@ import (
2727 "net/url"
2828 "regexp"
2929 "strconv"
30- "strings"
3130 "time"
3231
3332 "github.com/google/go-github/v44/github"
@@ -143,35 +142,21 @@ func (s *GithubReleaseSource) ListAllFiles(out chan<- FileSpec) *ListEntriesErro
143142 }
144143 }
145144
146- var assets []* github.ReleaseAsset
147145 for _ , r := range releases {
148146 if ! s .IncludeDraft && r .GetDraft () {
149147 continue
150148 }
151149 if ! s .IncludePrerelease && r .GetPrerelease () {
152150 continue
153151 }
154- if s .TagNamePattern != "" && ! s .tagNameRx .MatchString (r .GetTagName ()) {
152+ tagName := r .GetTagName ()
153+ if s .TagNamePattern != "" && ! s .tagNameRx .MatchString (tagName ) {
155154 continue
156155 }
157156
158- releaseID := r .GetID ()
159- aL , err := s .getReleaseAssets (releaseID )
160- if err != nil {
161- return & ListEntriesError {
162- Location : s .url .String (),
163- Message : fmt .Sprintf ("could not list release assets for release %d" , releaseID ),
164- Inner : err ,
165- }
166- }
167- assets = append (assets , aL ... )
168- }
169-
170- for _ , a := range assets {
171- if a .BrowserDownloadURL != nil {
157+ for _ , a := range r .Assets {
172158 fs := FileSpec {
173- // We need to remove the base URL from the path.
174- Path : strings .TrimPrefix (* a .BrowserDownloadURL , s .url .String ()),
159+ Path : fmt .Sprintf ("%s/%s" , tagName , a .GetName ()),
175160 // Technically, DownloadPath is supposed to be a file path but since we
176161 // only need asset ID to download the asset in GetFile() therefore we can
177162 // simply use the asset ID here instead.
@@ -261,25 +246,3 @@ func (s *GithubReleaseSource) getReleases() ([]*github.RepositoryRelease, error)
261246
262247 return result , nil
263248}
264-
265- func (s * GithubReleaseSource ) getReleaseAssets (releaseID int64 ) ([]* github.ReleaseAsset , error ) {
266- var result []* github.ReleaseAsset
267-
268- // Set higher value than default (30) for results per page to avoid exceeding API rate limit.
269- listOpts := & github.ListOptions {PerPage : 50 }
270- resp := & github.Response {NextPage : 1 }
271- for resp .NextPage != 0 {
272- var (
273- aL []* github.ReleaseAsset
274- err error
275- )
276- listOpts .Page = resp .NextPage
277- aL , resp , err = s .client .Repositories .ListReleaseAssets (context .Background (), s .owner , s .repo , releaseID , listOpts )
278- if err != nil {
279- return nil , err
280- }
281- result = append (result , aL ... )
282- }
283-
284- return result , nil
285- }
0 commit comments