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

Function isNewRelease

pkg/cmd/release/create/http.go:238–267  ·  view source on GitHub ↗

isNewRelease checks if there are new commits since the latest release.

(httpClient *http.Client, repo ghrepo.Interface)

Source from the content-addressed store, hash-verified

236
237// isNewRelease checks if there are new commits since the latest release.
238func isNewRelease(httpClient *http.Client, repo ghrepo.Interface) (bool, error) {
239 ctx := context.Background()
240 release, err := shared.FetchLatestRelease(ctx, httpClient, repo)
241 if err != nil {
242 if errors.Is(err, shared.ErrReleaseNotFound) {
243 return true, nil
244 } else {
245 return false, err
246 }
247 }
248
249 tagName := release.TagName
250 u, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "compare", tagName+"...HEAD")
251 if err != nil {
252 return false, err
253 }
254 u.SetQuery("per_page", "1")
255
256 var comparisonStatus struct {
257 Status string `json:"status"`
258 }
259
260 apiClient := api.NewClientFromHTTP(httpClient)
261 if err := apiClient.REST(repo.RepoHost(), "GET", u.String(), nil, &comparisonStatus); err != nil {
262 return false, err
263 }
264
265 isNew := comparisonStatus.Status == "ahead"
266 return isNew, nil
267}

Callers 1

createRunFunction · 0.85

Calls 9

FetchLatestReleaseFunction · 0.92
JoinPathFunction · 0.92
NewClientFromHTTPFunction · 0.92
SetQueryMethod · 0.80
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTMethod · 0.65
RepoHostMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected