fetchReleaseFromTag finds release by tag name for a repository
(httpClient *http.Client, baseRepo ghrepo.Interface, tagName string)
| 145 | |
| 146 | // fetchReleaseFromTag finds release by tag name for a repository |
| 147 | func fetchReleaseFromTag(httpClient *http.Client, baseRepo ghrepo.Interface, tagName string) (*release, error) { |
| 148 | path, err := safeurl.JoinPath("repos", baseRepo.RepoOwner(), baseRepo.RepoName(), "releases", "tags", tagName) |
| 149 | if err != nil { |
| 150 | return nil, err |
| 151 | } |
| 152 | |
| 153 | var data json.RawMessage |
| 154 | // TODO(api-client-rollout) |
| 155 | // This line of code is part of a mechanical roll out of the api client. |
| 156 | // As a follow up, consider whether the api client can be injected to this call site, rather than constructed |
| 157 | err = api.NewClientFromHTTP(httpClient).REST(baseRepo.RepoHost(), http.MethodGet, path.String(), nil, &data) |
| 158 | if err != nil { |
| 159 | var httpErr api.HTTPError |
| 160 | if errors.As(err, &httpErr) && httpErr.StatusCode == http.StatusNotFound { |
| 161 | return nil, releaseNotFoundErr |
| 162 | } |
| 163 | return nil, err |
| 164 | } |
| 165 | |
| 166 | var r release |
| 167 | if err := json.Unmarshal(data, &r); err != nil { |
| 168 | return nil, err |
| 169 | } |
| 170 | |
| 171 | return &r, nil |
| 172 | } |
| 173 | |
| 174 | // fetchCommitSHA finds full commit SHA from a target ref in a repo |
| 175 | func fetchCommitSHA(httpClient *http.Client, baseRepo ghrepo.Interface, targetRef string) (string, error) { |