MCPcopy
hub / github.com/cli/cli / isNewRelease

Function isNewRelease

pkg/cmd/release/create/http.go:305–330  ·  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

303
304// isNewRelease checks if there are new commits since the latest release.
305func isNewRelease(httpClient *http.Client, repo ghrepo.Interface) (bool, error) {
306 ctx := context.Background()
307 release, err := shared.FetchLatestRelease(ctx, httpClient, repo)
308 if err != nil {
309 if errors.Is(err, shared.ErrReleaseNotFound) {
310 return true, nil
311 } else {
312 return false, err
313 }
314 }
315
316 tagName := release.TagName
317 path := fmt.Sprintf("repos/%s/%s/compare/%s...HEAD?per_page=1", repo.RepoOwner(), repo.RepoName(), tagName)
318
319 var comparisonStatus struct {
320 Status string `json:"status"`
321 }
322
323 apiClient := api.NewClientFromHTTP(httpClient)
324 if err := apiClient.REST(repo.RepoHost(), "GET", path, nil, &comparisonStatus); err != nil {
325 return false, err
326 }
327
328 isNew := comparisonStatus.Status == "ahead"
329 return isNew, nil
330}

Callers 1

createRunFunction · 0.85

Calls 6

FetchLatestReleaseFunction · 0.92
NewClientFromHTTPFunction · 0.92
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RESTMethod · 0.65
RepoHostMethod · 0.65

Tested by

no test coverage detected