MCPcopy
hub / github.com/cli/cli / GetGist

Function GetGist

pkg/cmd/gist/shared/shared.go:63–78  ·  view source on GitHub ↗
(client *http.Client, hostname, gistID string)

Source from the content-addressed store, hash-verified

61var NotFoundErr = errors.New("not found")
62
63func GetGist(client *http.Client, hostname, gistID string) (*Gist, error) {
64 gist := Gist{}
65 path := fmt.Sprintf("gists/%s", gistID)
66
67 apiClient := api.NewClientFromHTTP(client)
68 err := apiClient.REST(hostname, "GET", path, nil, &gist)
69 if err != nil {
70 var httpErr api.HTTPError
71 if errors.As(err, &httpErr) && httpErr.StatusCode == 404 {
72 return nil, NotFoundErr
73 }
74 return nil, err
75 }
76
77 return &gist, nil
78}
79
80func GistIDFromURL(gistURL string) (string, error) {
81 u, err := url.Parse(gistURL)

Callers 4

deleteRunFunction · 0.92
viewRunFunction · 0.92
renameRunFunction · 0.92
editRunFunction · 0.92

Calls 2

NewClientFromHTTPFunction · 0.92
RESTMethod · 0.65

Tested by

no test coverage detected