MCPcopy Create free account
hub / github.com/cli/cli / repoExists

Function repoExists

pkg/cmd/extension/http.go:16–40  ·  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, err := safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(repo.RepoHost()), "repos", repo.RepoOwner(), repo.RepoName())
18 if err != nil {
19 return false, err
20 }
21 req, err := http.NewRequest("GET", url.String(), nil)
22 if err != nil {
23 return false, err
24 }
25
26 resp, err := httpClient.Do(req)
27 if err != nil {
28 return false, err
29 }
30 defer resp.Body.Close()
31
32 switch resp.StatusCode {
33 case 200:
34 return true, nil
35 case 404:
36 return false, nil
37 default:
38 return false, api.HandleHTTPError(resp)
39 }
40}
41
42func hasScript(httpClient *http.Client, repo ghrepo.Interface) (bool, error) {
43 url, err := safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(repo.RepoHost()), "repos", repo.RepoOwner(), repo.RepoName(), "contents", repo.RepoName())

Callers 1

InstallMethod · 0.85

Calls 9

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

Tested by

no test coverage detected