You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
show-open-prs-of-forks includes unrelated PRs #2934
Oof. From what I can tell, GitHub has no search filter in place to limit results to a certain head repo.
This creates two problems:
We can't determine the exact number of open PRs without fetching a lot more data from the API than we do now. (At least I think we can't. There may be a possibility to utilize the GraphQL API in a way which can filter for certain nested node values. But since I have no considerable knowledge of GraphQL, I can't tell whether or not this is possible.)
We also can't reliably link to a list of open PRs since that link is entirely composed of issue search filters.
I'm not sure how to handle this.
We could solve part of it by checking if the user has write access not only to the forked repo but also to the source repo. This should be solvable in one API request and could be cached for a long time.
If the user has no write access to the source repo, we should be fine keeping the current process in place.
If the user has write access to the source repo (as in your reproduction setup), we may consider fetching individual pull requests from the API and filtering them by head repo on the client side. We then could forego linking to a list of PRs and just tell the user about the fact that there are open PRs.
Yes, I had tried it out in the explorer, that's basically how I imagined it to be implemented. The "lot" of data was more in comparison with before, and it grows linearly with number of PRs.
I think this would be a reasonable implementation. In the (probably a bit absurd) case that somebody has > 100 open PRs, I'd bail out of counting.
I don’t expect anyone to have a considerable amount of PRs open from a fork, they’re distant outliers.
As for the link, there’s no direct fix, but:
I’d expect people to open PRs from the fork OR the source, not at the same time (generally)
if they do have mixed repos, our pr-branches feature will help them understand which is which
Alternatively, I think that the search accepts searching by number and logical operators. If that works, we could link to the search issue:2 OR issue:30 OR issue:40Not possible
If some one wants to send a PR I tested #2934 (comment) and it looks fine to me. (I changed it to headRepository because I think that is correct) yakov116@b698cf3
@@ -17,24 +17,28 @@ const countPRs = cache.function(async (forkedRepo: string): Promise<[number, num
// This allows to link to the PR directly if only one is found
const {search} = await api.v4(`
search(
- first: 1,+ first: 100,
type: ISSUE,
query: "repo:${forkedRepo} is:pr is:open author:${getUsername()}"
) {
- issueCount
nodes {
... on PullRequest {
number
+ headRepository {+ nameWithOwner+ }
}
}
}
`);
- if (search.issueCount === 1) {- return [1, search.nodes[0].number];+ const prs = search.nodes.filter((pr: AnyObject) => pr.headRepository.nameWithOwner.toLowerCase() === getRepoURL());++ if (prs.length === 1) {+ return [1, prs[0].number];
}
- return [search.issueCount];+ return [prs.length];
}, {
maxAge: 1 / 2, // Stale after 12 hours
staleWhileRevalidate: 2,
Activity
loilo commentedon Mar 25, 2020
Fair point. I'll take care of it. 🙂
loilo commentedon Mar 25, 2020
Oof. From what I can tell, GitHub has no search filter in place to limit results to a certain head repo.
This creates two problems:
I'm not sure how to handle this.
We could solve part of it by checking if the user has write access not only to the forked repo but also to the source repo. This should be solvable in one API request and could be cached for a long time.
What do you think @fregante?
fregante commentedon Mar 25, 2020
Here: https://developer.github.com/v4/explorer/
We'd have to fetch all your PR info, not just the first one, but it's not a lot of data.
{ "data": { "search": { "nodes": [ { "baseRepository": { "nameWithOwner": "sindresorhus/refined-github" }, "number": 2925 } ] } } }Then something like:
loilo commentedon Mar 26, 2020
Yes, I had tried it out in the explorer, that's basically how I imagined it to be implemented. The "lot" of data was more in comparison with before, and it grows linearly with number of PRs.
I think this would be a reasonable implementation. In the (probably a bit absurd) case that somebody has > 100 open PRs, I'd bail out of counting.
How'd you deal with the link problem?
fregante commentedon Mar 26, 2020
I don’t expect anyone to have a considerable amount of PRs open from a fork, they’re distant outliers.
As for the link, there’s no direct fix, but:
pr-branchesfeature will help them understand which is whichAlternatively, I think that the search accepts searching by number and logical operators. If that works, we could link to the searchNot possibleissue:2 OR issue:30 OR issue:40loilo commentedon Mar 26, 2020
[-]`show-open-prs-of-forks` includes unrelated forks[/-][+]`show-open-prs-of-forks` includes unrelated PRs[/+]yakov116 commentedon May 4, 2020
If some one wants to send a PR I tested #2934 (comment) and it looks fine to me. (I changed it to headRepository because I think that is correct)
yakov116@b698cf3