isNewRelease checks if there are new commits since the latest release.
(httpClient *http.Client, repo ghrepo.Interface)
| 303 | |
| 304 | // isNewRelease checks if there are new commits since the latest release. |
| 305 | func 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 | } |
no test coverage detected