MCPcopy
hub / github.com/cli/cli / publishedReleaseExists

Function publishedReleaseExists

pkg/cmd/release/create/http.go:144–167  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface, tagName string)

Source from the content-addressed store, hash-verified

142}
143
144func publishedReleaseExists(httpClient *http.Client, repo ghrepo.Interface, tagName string) (bool, error) {
145 path := fmt.Sprintf("repos/%s/%s/releases/tags/%s", repo.RepoOwner(), repo.RepoName(), url.PathEscape(tagName))
146 url := ghinstance.RESTPrefix(repo.RepoHost()) + path
147 req, err := http.NewRequest("HEAD", url, nil)
148 if err != nil {
149 return false, err
150 }
151
152 resp, err := httpClient.Do(req)
153 if err != nil {
154 return false, err
155 }
156 if resp.Body != nil {
157 defer resp.Body.Close()
158 }
159
160 if resp.StatusCode == 200 {
161 return true, nil
162 } else if resp.StatusCode == 404 {
163 return false, nil
164 } else {
165 return false, api.HandleHTTPError(resp)
166 }
167}
168
169func createRelease(httpClient *http.Client, repo ghrepo.Interface, params map[string]interface{}) (*shared.Release, error) {
170 bodyBytes, err := json.Marshal(params)

Callers 1

createRunFunction · 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