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