(httpClient *http.Client, baseRepo ghrepo.Interface, prNumber int, asPatch bool)
| 210 | } |
| 211 | |
| 212 | func fetchDiff(httpClient *http.Client, baseRepo ghrepo.Interface, prNumber int, asPatch bool) (io.ReadCloser, error) { |
| 213 | path, err := safeurl.JoinPath("repos", baseRepo.RepoOwner(), baseRepo.RepoName(), "pulls", strconv.Itoa(prNumber)) |
| 214 | if err != nil { |
| 215 | return nil, err |
| 216 | } |
| 217 | acceptType := "application/vnd.github.v3.diff" |
| 218 | if asPatch { |
| 219 | acceptType = "application/vnd.github.v3.patch" |
| 220 | } |
| 221 | |
| 222 | // TODO(api-client-rollout) |
| 223 | // This line of code is part of a mechanical roll out of the api client. |
| 224 | // As a follow up, consider whether the api client can be injected to this call site, rather than constructed |
| 225 | resp, err := api.NewClientFromHTTP(httpClient).Request(baseRepo.RepoHost(), http.MethodGet, path.String(), nil, |
| 226 | api.WithHeader("Accept", acceptType)) |
| 227 | if err != nil { |
| 228 | return nil, err |
| 229 | } |
| 230 | if resp.StatusCode != 200 { |
| 231 | defer resp.Body.Close() |
| 232 | return nil, api.UnexpectedStatusError(resp) |
| 233 | } |
| 234 | |
| 235 | return resp.Body, nil |
| 236 | } |
| 237 | |
| 238 | const lineBufferSize = 4096 |
| 239 |
no test coverage detected