MCPcopy Index your code
hub / github.com/cli/cli / fetchReleasePath

Function fetchReleasePath

pkg/cmd/release/shared/fetch.go:266–291  ·  view source on GitHub ↗
(ctx context.Context, httpClient *http.Client, host string, p string)

Source from the content-addressed store, hash-verified

264}
265
266func fetchReleasePath(ctx context.Context, httpClient *http.Client, host string, p string) (*Release, error) {
267 req, err := http.NewRequestWithContext(ctx, "GET", ghinstance.RESTPrefix(host)+p, nil)
268 if err != nil {
269 return nil, err
270 }
271
272 resp, err := httpClient.Do(req)
273 if err != nil {
274 return nil, err
275 }
276 defer resp.Body.Close()
277
278 if resp.StatusCode == http.StatusNotFound {
279 _, _ = io.Copy(io.Discard, resp.Body)
280 return nil, ErrReleaseNotFound
281 } else if resp.StatusCode > 299 {
282 return nil, api.HandleHTTPError(resp)
283 }
284
285 var release Release
286 if err := json.NewDecoder(resp.Body).Decode(&release); err != nil {
287 return nil, err
288 }
289
290 return &release, nil
291}
292
293func StubFetchRelease(t *testing.T, reg *httpmock.Registry, owner, repoName, tagName, responseBody string) {
294 path := "repos/OWNER/REPO/releases/tags/v1.2.3"

Callers 3

FetchReleaseFunction · 0.85
FetchLatestReleaseFunction · 0.85
fetchDraftReleaseFunction · 0.85

Calls 5

RESTPrefixFunction · 0.92
HandleHTTPErrorFunction · 0.92
DoMethod · 0.65
CloseMethod · 0.65
CopyMethod · 0.45

Tested by

no test coverage detected