`gh pr view --json commits` is limited to 100 commits
When requesting commits in a PR with gh pr view <PR> --json commits, only the first 100 commits are shown. All commits should be returned. In my use case I only need the latest commit (to update a PR check status), and it becomes inaccessible for PRs with more than 100 commits.
I assume this is related to #3040 and #5368.
@Nohus Yup this is the same restriction as #5368. Going to reclassify as an enhancement and we will make sure to tackle this at the same time.
@Nohus Yup this is the same restriction as #5368. Going to reclassify as an enhancement and we will make sure to tackle this at the same time.
Hello, any progress on that one? I got hit by this issue, also there is no note in the documentation that there is any limitation.
I also got bitten by this after I developed a CI for a repo, and it started failing on PRs with more than 100 commits. I'll look into using the API directly as shown at https://github.com/cli/cli/issues/5368#issuecomment-1087515074
Edit: I didn't need to use the github API in the end. For my needs I just needed to extract the latest commit in a PR, so I did
steps:
- name: Checkout PR current git branch
# Don't use 'gh pr checkout' because the repo has not been checked out up until this point.
id: extractCommit
run: |
echo "sha='$(gh pr view '${{ github.event.pull_request.number || github.event.issue.number }}' --json headRefOid --jq '.headRefOid' --repo ${{ github.repository }})'" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}
- name: Checkout git branch
uses: actions/checkout@v3
with:
ref: ${{ steps.extractCommit.outputs.sha }}