(httpClient *http.Client, baseRepo ghrepo.Interface, prNumber int, asPatch bool)
| 186 | } |
| 187 | |
| 188 | func fetchDiff(httpClient *http.Client, baseRepo ghrepo.Interface, prNumber int, asPatch bool) (io.ReadCloser, error) { |
| 189 | url := fmt.Sprintf( |
| 190 | "%srepos/%s/pulls/%d", |
| 191 | ghinstance.RESTPrefix(baseRepo.RepoHost()), |
| 192 | ghrepo.FullName(baseRepo), |
| 193 | prNumber, |
| 194 | ) |
| 195 | acceptType := "application/vnd.github.v3.diff" |
| 196 | if asPatch { |
| 197 | acceptType = "application/vnd.github.v3.patch" |
| 198 | } |
| 199 | |
| 200 | req, err := http.NewRequest("GET", url, nil) |
| 201 | if err != nil { |
| 202 | return nil, err |
| 203 | } |
| 204 | |
| 205 | req.Header.Set("Accept", acceptType) |
| 206 | |
| 207 | resp, err := httpClient.Do(req) |
| 208 | if err != nil { |
| 209 | return nil, err |
| 210 | } |
| 211 | if resp.StatusCode != 200 { |
| 212 | return nil, api.HandleHTTPError(resp) |
| 213 | } |
| 214 | |
| 215 | return resp.Body, nil |
| 216 | } |
| 217 | |
| 218 | const lineBufferSize = 4096 |
| 219 |
no test coverage detected