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

Function publishedReleaseExists

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

Source from the content-addressed store, hash-verified

148}
149
150func publishedReleaseExists(httpClient *http.Client, repo ghrepo.Interface, tagName string) (bool, error) {
151 url, err := safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(repo.RepoHost()), "repos", repo.RepoOwner(), repo.RepoName(), "releases", "tags", tagName)
152 if err != nil {
153 return false, err
154 }
155 req, err := http.NewRequest("HEAD", url.String(), nil)
156 if err != nil {
157 return false, err
158 }
159
160 resp, err := httpClient.Do(req)
161 if err != nil {
162 return false, err
163 }
164 if resp.Body != nil {
165 defer resp.Body.Close()
166 }
167
168 if resp.StatusCode == 200 {
169 return true, nil
170 } else if resp.StatusCode == 404 {
171 return false, nil
172 } else {
173 return false, api.HandleHTTPError(resp)
174 }
175}
176
177func createRelease(httpClient *http.Client, repo ghrepo.Interface, params map[string]interface{}) (*shared.Release, error) {
178 bodyBytes, err := json.Marshal(params)

Callers 1

createRunFunction · 0.85

Calls 9

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

Tested by

no test coverage detected