MCPcopy
hub / github.com/cli/cli / hasScript

Function hasScript

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

Source from the content-addressed store, hash-verified

37}
38
39func hasScript(httpClient *http.Client, repo ghrepo.Interface) (bool, error) {
40 path := fmt.Sprintf("repos/%s/%s/contents/%s",
41 repo.RepoOwner(), repo.RepoName(), repo.RepoName())
42 url := ghinstance.RESTPrefix(repo.RepoHost()) + path
43 req, err := http.NewRequest("GET", url, nil)
44 if err != nil {
45 return false, err
46 }
47
48 resp, err := httpClient.Do(req)
49 if err != nil {
50 return false, err
51 }
52 defer resp.Body.Close()
53
54 if resp.StatusCode == 404 {
55 return false, nil
56 }
57
58 if resp.StatusCode > 299 {
59 err = api.HandleHTTPError(resp)
60 return false, err
61 }
62
63 return true, nil
64}
65
66type releaseAsset struct {
67 Name string

Callers 1

InstallMethod · 0.85

Calls 7

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

Tested by

no test coverage detected