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

Function editRelease

pkg/cmd/release/edit/http.go:19–57  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface, releaseID int64, params map[string]any)

Source from the content-addressed store, hash-verified

17)
18
19func editRelease(httpClient *http.Client, repo ghrepo.Interface, releaseID int64, params map[string]any) (*shared.Release, error) {
20 bodyBytes, err := json.Marshal(params)
21 if err != nil {
22 return nil, err
23 }
24
25 url, err := safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(repo.RepoHost()), "repos", repo.RepoOwner(), repo.RepoName(), "releases", strconv.FormatInt(releaseID, 10))
26 if err != nil {
27 return nil, err
28 }
29 req, err := http.NewRequest("PATCH", url.String(), bytes.NewBuffer(bodyBytes))
30 if err != nil {
31 return nil, err
32 }
33
34 req.Header.Set("Content-Type", "application/json; charset=utf-8")
35
36 // TODO(api-client-rollout)
37 // This has been deferred from moving to api.Client because its return shape depends on the response status code, which api.Client.REST does not expose on success.
38 resp, err := httpClient.Do(req)
39 if err != nil {
40 return nil, err
41 }
42 defer resp.Body.Close()
43
44 success := resp.StatusCode >= 200 && resp.StatusCode < 300
45 if !success {
46 return nil, api.HandleHTTPError(resp)
47 }
48
49 b, err := io.ReadAll(resp.Body)
50 if err != nil {
51 return nil, err
52 }
53
54 var newRelease shared.Release
55 err = json.Unmarshal(b, &newRelease)
56 return &newRelease, err
57}
58
59func remoteTagExists(httpClient *http.Client, repo ghrepo.Interface, tagName string) (bool, error) {
60 gql := api.NewClientFromHTTP(httpClient)

Callers 5

Test_editRelease_204Function · 0.85
editRunFunction · 0.85

Calls 10

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

Tested by 4

Test_editRelease_204Function · 0.68