(httpClient *http.Client, baseRepo ghrepo.Interface, prNumber int, asPatch bool)
| 211 | } |
| 212 | |
| 213 | func fetchDiff(httpClient *http.Client, baseRepo ghrepo.Interface, prNumber int, asPatch bool) (io.ReadCloser, error) { |
| 214 | url, err := safeurl.JoinPathWithHostPrefix(ghinstance.RESTPrefix(baseRepo.RepoHost()), "repos", baseRepo.RepoOwner(), baseRepo.RepoName(), "pulls", strconv.Itoa(prNumber)) |
| 215 | if err != nil { |
| 216 | return nil, err |
| 217 | } |
| 218 | acceptType := "application/vnd.github.v3.diff" |
| 219 | if asPatch { |
| 220 | acceptType = "application/vnd.github.v3.patch" |
| 221 | } |
| 222 | |
| 223 | req, err := http.NewRequest("GET", url.String(), nil) |
| 224 | if err != nil { |
| 225 | return nil, err |
| 226 | } |
| 227 | |
| 228 | req.Header.Set("Accept", acceptType) |
| 229 | |
| 230 | resp, err := httpClient.Do(req) |
| 231 | if err != nil { |
| 232 | return nil, err |
| 233 | } |
| 234 | if resp.StatusCode != 200 { |
| 235 | return nil, api.HandleHTTPError(resp) |
| 236 | } |
| 237 | |
| 238 | return resp.Body, nil |
| 239 | } |
| 240 | |
| 241 | const lineBufferSize = 4096 |
| 242 |
no test coverage detected