CompareCommitsRaw compares a range of commits with each other in raw (diff or patch) format. Both "base" and "head" must be branch names in "repo". To compare branches across other repositories in the same network as "repo", use the format " :branch". GitHub API docs: https://docs.github.
(ctx context.Context, owner, repo, base, head string, opts RawOptions)
| 271 | // |
| 272 | //meta:operation GET /repos/{owner}/{repo}/compare/{basehead} |
| 273 | func (s *RepositoriesService) CompareCommitsRaw(ctx context.Context, owner, repo, base, head string, opts RawOptions) (string, *Response, error) { |
| 274 | escapedBase := url.QueryEscape(base) |
| 275 | escapedHead := url.QueryEscape(head) |
| 276 | |
| 277 | u := fmt.Sprintf("repos/%v/%v/compare/%v...%v", owner, repo, escapedBase, escapedHead) |
| 278 | |
| 279 | req, err := s.client.NewRequest(ctx, "GET", u, nil) |
| 280 | if err != nil { |
| 281 | return "", nil, err |
| 282 | } |
| 283 | |
| 284 | switch opts.Type { |
| 285 | case Diff: |
| 286 | req.Header.Set("Accept", mediaTypeV3Diff) |
| 287 | case Patch: |
| 288 | req.Header.Set("Accept", mediaTypeV3Patch) |
| 289 | default: |
| 290 | return "", nil, fmt.Errorf("unsupported raw type %v", opts.Type) |
| 291 | } |
| 292 | |
| 293 | var buf bytes.Buffer |
| 294 | resp, err := s.client.Do(req, &buf) |
| 295 | if err != nil { |
| 296 | return "", resp, err |
| 297 | } |
| 298 | |
| 299 | return buf.String(), resp, nil |
| 300 | } |
| 301 | |
| 302 | // ListBranchesHeadCommit gets all branches where the given commit SHA is the HEAD, |
| 303 | // or latest commit for the branch. |