MCPcopy
hub / github.com/cli/cli / repoExists

Function repoExists

pkg/cmd/extension/http.go:16–37  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

14)
15
16func repoExists(httpClient *http.Client, repo ghrepo.Interface) (bool, error) {
17 url := fmt.Sprintf("%srepos/%s/%s", ghinstance.RESTPrefix(repo.RepoHost()), repo.RepoOwner(), repo.RepoName())
18 req, err := http.NewRequest("GET", url, nil)
19 if err != nil {
20 return false, err
21 }
22
23 resp, err := httpClient.Do(req)
24 if err != nil {
25 return false, err
26 }
27 defer resp.Body.Close()
28
29 switch resp.StatusCode {
30 case 200:
31 return true, nil
32 case 404:
33 return false, nil
34 default:
35 return false, api.HandleHTTPError(resp)
36 }
37}
38
39func hasScript(httpClient *http.Client, repo ghrepo.Interface) (bool, error) {
40 path := fmt.Sprintf("repos/%s/%s/contents/%s",

Callers 1

InstallMethod · 0.85

Calls 7

RESTPrefixFunction · 0.92
HandleHTTPErrorFunction · 0.92
RepoHostMethod · 0.65
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
DoMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected