MCPcopy Index your code
hub / github.com/cli/cli / fetchDiff

Function fetchDiff

pkg/cmd/pr/diff/diff.go:188–216  ·  view source on GitHub ↗
(httpClient *http.Client, baseRepo ghrepo.Interface, prNumber int, asPatch bool)

Source from the content-addressed store, hash-verified

186}
187
188func 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
218const lineBufferSize = 4096
219

Callers 1

diffRunFunction · 0.85

Calls 6

RESTPrefixFunction · 0.92
FullNameFunction · 0.92
HandleHTTPErrorFunction · 0.92
RepoHostMethod · 0.65
SetMethod · 0.65
DoMethod · 0.65

Tested by

no test coverage detected