( ctx context.Context, repo repoSlug, release *release, selection releaseSelection, )
| 532 | } |
| 533 | |
| 534 | func (c *Client) openDownloadResponse( |
| 535 | ctx context.Context, |
| 536 | repo repoSlug, |
| 537 | release *release, |
| 538 | selection releaseSelection, |
| 539 | ) (*http.Response, string, int64, error) { |
| 540 | switch { |
| 541 | case selection.asset != nil: |
| 542 | response, err := c.doRequest( |
| 543 | ctx, |
| 544 | firstNonEmpty(selection.asset.URL, selection.asset.BrowserDownloadURL), |
| 545 | acceptBinary, |
| 546 | ) |
| 547 | if err != nil { |
| 548 | return nil, "", -1, fmt.Errorf("github: download asset for %q: %w", repo.full, err) |
| 549 | } |
| 550 | size := int64(-1) |
| 551 | if selection.asset.Size > 0 { |
| 552 | size = selection.asset.Size |
| 553 | } |
| 554 | return response, strings.TrimSpace(selection.asset.Digest), size, nil |
| 555 | case selection.useTarball: |
| 556 | response, err := c.doRequest(ctx, strings.TrimSpace(release.TarballURL), acceptBinary) |
| 557 | if err != nil { |
| 558 | return nil, "", -1, fmt.Errorf("github: download source archive for %q: %w", repo.full, err) |
| 559 | } |
| 560 | return response, "", -1, nil |
| 561 | default: |
| 562 | return nil, "", -1, fmt.Errorf("github: no download candidate resolved for %q", repo.full) |
| 563 | } |
| 564 | } |
| 565 | |
| 566 | func finalizeDownloadResponse( |
| 567 | response *http.Response, |
no test coverage detected