cli icon indicating copy to clipboard operation
cli copied to clipboard

`gh pr view --json commits` is limited to 100 commits

Open Nohus opened this issue 3 years ago • 3 comments

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 avatar Apr 07 '22 08:04 Nohus

@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.

samcoe avatar Apr 07 '22 09:04 samcoe

@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.

Griffin641498 avatar Apr 22 '22 00:04 Griffin641498

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.

m4t22 avatar Aug 04 '22 09:08 m4t22

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 }}

bebosudo avatar Sep 04 '23 08:09 bebosudo