Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize github anno-prs and github checkout-prs for the case of 500+ PRs in a repo #1040

Open
PawelLipski opened this issue Sep 3, 2023 · 0 comments
Labels
github Relates to integration with GitHub performance Something works too slow

Comments

@PawelLipski
Copy link
Collaborator

As for now, all PRs are first fetched, even for git machete github checkout-prs <single-PR-number>, for the sake of traversing the PR chain upwards. This takes time due to the pagination limits (100 PRs at most in a single page, as of Sep 2023).

This is rather hard to optimize reasonably... we can consider fetching PRs for the matching set of head branches and/or author (only first match the PRs that have the given author).
/search/issues (v3) REST API cannot be used for that purpose as it does not include PR-specific fields that we can't do without (like head and base branches), only the stuff that's common to issues and PRs. Also, there's no /search/pulls.

Sample relevant v3 query:

curl -sL -H"Authorization: Bearer $(gh auth token)" https://api.github.com/search/issues?q=is:pr+state:open+repo:VirtusLab/git-machete+author:PawelLipski | jq -C | less -r

Thus, our only chance is GraphQL (v4) API. A sample query:

curl -sL -H"Authorization: Bearer $(gh auth token)" https://api.github.com/graphql -d "{\"query\": $(jq -R -s . < query.graphql)}" | jq -C | less -r

where query.graphql has:

{
  search(query: "is:pr author:PawelLipski repo:VirtusLab/git-machete", type: ISSUE, first: 100) {
  ### search(query: "is:pr author:PawelLipski repo:VirtusLab/git-machete", type: ISSUE, first: 100, after: "<endCursor>") {
    issueCount
    edges {
      node {
        ... on PullRequest {
          title
          url
          headRefName
          baseRefName
        }
      }
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
@PawelLipski PawelLipski added performance Something works too slow github Relates to integration with GitHub labels Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
github Relates to integration with GitHub performance Something works too slow
Projects
None yet
Development

No branches or pull requests

1 participant