Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List commits on a pull request

I see that for commits on a pull request, max limit is 250 as per the document: List commits on a Pull Request and if the pull request exceeds 250 commits then another end-point is suggested which is: List Commits

Lists a maximum of 250 commits for a pull request. To receive a complete commit list for pull requests with more than 250 commits, use the List commits endpoint.

GET /repos/:owner/:repo/pulls/:pull_number/commits

But, I dont see how using List Commits end-point I can figure out if its tied to the pull request.

EDIT: Wondering, if I should rely on git commands here instead. i.e clone the repo, run git log to get a list of all commits.. Any better approach? Issue: Not all commits would have been pushed to the pull request?

Also, I am looking for a way to see if there are any new commits incrementally added to pull request since it was first raised. For cases, where review comments are worked on and added to existing pull request, in that case I wish to just validate incremental changes. Any pointers or document on how to achieve that?

like image 966
iDev Avatar asked Jul 17 '26 09:07

iDev


1 Answers

The GitHub CLI can list PR commits. Handily, the CLI is pre-installed on GitHub Actions runners.

gh pr view 19 --json commits
{
  "commits": [
    {
      "authoredDate": "2022-11-21T20:36:33Z",
      "authors": [
        {
          "email": "[email protected]",
          "id": "MDQ6VXNlcjE2Nzc5NTU=",
          "login": "someone",
          "name": "someone"
        }
      ],
      "committedDate": "2022-11-21T20:36:33Z",
      "messageBody": "",
      "messageHeadline": "chore(main): release 0.3.5",
      "oid": "7da95da24f502d32bbdc01a117bc881bad6007df"
    }
  ]
}
like image 61
fedonev Avatar answered Jul 23 '26 18:07

fedonev