MCPcopy Index your code
hub / github.com/google/go-github / GetArchiveLink

Method GetArchiveLink

github/repos_contents.go:337–348  ·  view source on GitHub ↗

GetArchiveLink returns an URL to download a tarball or zipball archive for a repository. The archiveFormat can be specified by either the github.Tarball or github.Zipball constant. GitHub API docs: https://docs.github.com/rest/repos/contents?apiVersion=2022-11-28#download-a-repository-archive-tar

(ctx context.Context, owner, repo string, archiveformat ArchiveFormat, opts *RepositoryContentGetOptions, maxRedirects int)

Source from the content-addressed store, hash-verified

335//meta:operation GET /repos/{owner}/{repo}/tarball/{ref}
336//meta:operation GET /repos/{owner}/{repo}/zipball/{ref}
337func (s *RepositoriesService) GetArchiveLink(ctx context.Context, owner, repo string, archiveformat ArchiveFormat, opts *RepositoryContentGetOptions, maxRedirects int) (*url.URL, *Response, error) {
338 u := fmt.Sprintf("repos/%v/%v/%v", owner, repo, archiveformat)
339 if opts != nil && opts.Ref != "" {
340 u += fmt.Sprintf("/%v", opts.Ref)
341 }
342
343 if s.client.rateLimitRedirectionalEndpoints {
344 return s.getArchiveLinkWithRateLimit(ctx, u, maxRedirects)
345 }
346
347 return s.getArchiveLinkWithoutRateLimit(ctx, u, maxRedirects)
348}
349
350func (s *RepositoriesService) getArchiveLinkWithoutRateLimit(ctx context.Context, u string, maxRedirects int) (*url.URL, *Response, error) {
351 resp, err := s.client.roundTripWithOptionalFollowRedirect(ctx, u, maxRedirects)