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
}
}
}
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:
Thus, our only chance is GraphQL (v4) API. A sample query:
where
query.graphqlhas:{ 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 } } }