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
Or by checking the refs/branches of the fork for open PRs
I think this really depends on what this feature should do.
With the second aproach it would be possible to check if there are any open PRs on any repository.
The query for this could look like this: (Maybe also hoping no one has over 100 branches in their fork 🙈)
If the sum of all associatedPullRequests is greater then zero then this repo should probably not be deleted.
But these PRs could also include open PRs to the fork itself, not sure if that should be handled.
It would also be possible to check for isCrossRepository and get the url of the PR if that is needed.
My guess is that associatedPullRequests includes both local and cross-repo PRs, so if if there are 5 local PRs and 2 cross repo, the count returned should be 7. The Pull Request tab would show 5 and we could attach a +2 right next to it.
Additionally we could show “there are X open PRs from this repo” on the deletion page/popup
This might require to only count the isCrossRepository PRs, because the PR tab could also contain PRs from other repository (e.g. if the fork got forked again).
Maybe we could also just ignore those edgecases but I just wanted to point that out.
So the query would then be like this: (I included the PR count of the current repository, we can also just parse the html)
No you don’t need to query it from the API because the number is already in the tab itself, right?
Yes it wouldn't be needed but it doesn't really complicate the query so I think it wouldn't matter where to get it from.
It might be usfull if we also would like to know how many pullRequests are cross repository.
Wow, I did not find anything about this via search, so I just typed out a whole issue to suggest this feature... but I guess GitHub's "similar issues" feature got the better of me. 😁
I'm not familiar with the v4 API, but I found a very easy v3 request to get the according PRs using the /search/issues endpoint (example for my fork of mautic/mautic):
You can use GitHub GraphQL Explorer to figure it out. The good part is that the response will literally be 20 bytes of text instead of KBs of useless data that the v3 API returns.
Activity
fregante commentedon Aug 5, 2019
Possible starting point: https://stackoverflow.com/a/55125453/288906
Esemesek commentedon Aug 7, 2019
I can take care of it. Already played with GraphQL queries for this and I found a possible solution.
{ search(query: "repo:sindresorhus/refined-github is:pr is:open author:Esemesek", type: ISSUE, last: 100) { edges { node { ... on PullRequest { url title createdAt isCrossRepository headRepository { owner { login } name } } } } } }With this query, we should be able to find out all the open PRs for a fork.
fregante commentedon Aug 7, 2019
Sounds good
issuehunt-oss commentedon Nov 3, 2019
@jerone has funded $5.00 to this issue.
dertieran commentedon Dec 5, 2019
I think there are two approachs to do this
I think this really depends on what this feature should do.
With the second aproach it would be possible to check if there are any open PRs on any repository.
The query for this could look like this:
(Maybe also hoping no one has over 100 branches in their fork 🙈)
{ repository(name: "refined-github", owner: "busches") { refs(refPrefix: "refs/heads/", first: 100) { nodes { associatedPullRequests(states: OPEN) { totalCount } } } } }Example Response
{ "data": { "repository": { "refs": { "nodes": [ { "associatedPullRequests": { "totalCount": 1 } }, { "associatedPullRequests": { "totalCount": 0 } } ] } } } }If the sum of all
associatedPullRequestsis greater then zero then this repo should probably not be deleted.But these PRs could also include open PRs to the fork itself, not sure if that should be handled.
It would also be possible to check for
isCrossRepositoryand get theurlof the PR if that is needed.I already have a working example for this here.
Screenshots
So I guess it now depends what should be displayed where and if all PRs of the fork count or just cross repository or even only to the parent.
fregante commentedon Dec 6, 2019
My guess is that associatedPullRequests includes both local and cross-repo PRs, so if if there are 5 local PRs and 2 cross repo, the count returned should be 7. The Pull Request tab would show 5 and we could attach a
+2right next to it.Additionally we could show “there are X open PRs from this repo” on the deletion page/popup
dertieran commentedon Dec 6, 2019
This might require to only count the
isCrossRepositoryPRs, because the PR tab could also contain PRs from other repository (e.g. if the fork got forked again).Maybe we could also just ignore those edgecases but I just wanted to point that out.
So the query would then be like this:
(I included the PR count of the current repository, we can also just parse the html)
{ repository(name: "refined-github", owner: "busches") { pullRequests(states: OPEN) { totalCount } refs(refPrefix: "refs/heads/", first: 100) { nodes { associatedPullRequests(states: OPEN, first: 100) { nodes { isCrossRepository } } } } } }fregante commentedon Dec 6, 2019
No you don’t need to query it from the API because the number is already in the tab itself, right?
dertieran commentedon Dec 6, 2019
Yes it wouldn't be needed but it doesn't really complicate the query so I think it wouldn't matter where to get it from.
It might be usfull if we also would like to know how many
pullRequestsare cross repository.loilo commentedon Mar 10, 2020
Wow, I did not find anything about this via search, so I just typed out a whole issue to suggest this feature... but I guess GitHub's "similar issues" feature got the better of me. 😁
I'm not familiar with the v4 API, but I found a very easy v3 request to get the according PRs using the
/search/issuesendpoint (example for my fork ofmautic/mautic):https://api.github.com/search/issues?q=repo:mautic/mautic+is:pr+is:open+author:loilo
I'd be happy to implement this. The visualization in the header could be like this:
What do you think?
fregante commentedon Mar 10, 2020
It looks great! API v4 should work similarly, the query should be something like, off of my head:
{ search(query: 'blah blah', type: ISSUE) { issueCount } }You can use GitHub GraphQL Explorer to figure it out. The good part is that the response will literally be 20 bytes of text instead of KBs of useless data that the v3 API returns.
loilo commentedon Mar 10, 2020
Good point. I'll try to figure it out.
issuehunt-oss commentedon Mar 31, 2020
@sindresorhus has rewarded $4.50 to @loilo. See it on IssueHunt