| 42 | } |
| 43 | |
| 44 | func hasScript(httpClient *http.Client, repo ghrepo.Interface) (bool, error) { |
| 45 | path, err := safeurl.JoinPath("repos", repo.RepoOwner(), repo.RepoName(), "contents", repo.RepoName()) |
| 46 | if err != nil { |
| 47 | return false, err |
| 48 | } |
| 49 | |
| 50 | // The response body is not decoded, because a script is considered present for any |
| 51 | // successful response regardless of the content type reported. |
| 52 | // TODO(api-client-rollout) |
| 53 | // This line of code is part of a mechanical roll out of the api client. |
| 54 | // As a follow up, consider whether the api client can be injected to this call site, rather than constructed |
| 55 | err = api.NewClientFromHTTP(httpClient).REST(repo.RepoHost(), http.MethodGet, path.String(), nil, nil) |
| 56 | if err != nil { |
| 57 | var httpErr api.HTTPError |
| 58 | if errors.As(err, &httpErr) && httpErr.StatusCode == http.StatusNotFound { |
| 59 | return false, nil |
| 60 | } |
| 61 | return false, err |
| 62 | } |
| 63 | |
| 64 | return true, nil |
| 65 | } |
| 66 | |
| 67 | type releaseAsset struct { |
| 68 | Name string |