Skip to content

Find open PRs on your forks #2268

Closed

Description

@fregante

Issuehunt badges

Usually forks are only useful to send PRs. When your open PRs are merged, they should be deleted.

Finding out whether your fork is still needed takes too long (open source repo, go to PRs, look for your PRs).

Refined GitHub should mention your open PRs in:

  • your forked repo's header (perhaps even adding a tab next to the original "Pull requests (0)" tab)
  • In the "Delete repo" lightbox ("you have x PRs open" or "no PRs are open, you can delete it")

Ideally this should check whether there are any branches ahead of source like https://github.com/denis-sokolov/remove-github-forks does, but checking for PRs alone would make this feature a good companion to that CLI tool.


IssueHunt Summary

loilo loilo has been rewarded.

Backers (Total: $5.00)

Submitted pull Requests


Tips


IssueHunt has been backed by the following sponsors. Become a sponsor

Activity

  1. Esemesek commented on Aug 7, 2019

    @Esemesek
    Contributor

    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.

  2. fregante commented on Aug 7, 2019

    @fregante
    MemberAuthor

    Sounds good

  3. issuehunt-oss commented on Nov 3, 2019

    @issuehunt-oss

    @jerone has funded $5.00 to this issue.


  4. added
    💵 Funded on Issuehunt
    on Nov 3, 2019
  5. dertieran commented on Dec 5, 2019

    @dertieran
    Contributor

    I think there are two approachs to do this

    1. By checking the PRs of the parent repository
    2. 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 🙈)

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

    I already have a working example for this here.

    Screenshots

    image
    image

    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.

  6. fregante commented on Dec 6, 2019

    @fregante
    MemberAuthor

    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

  7. dertieran commented on Dec 6, 2019

    @dertieran
    Contributor

    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)

    {
      repository(name: "refined-github", owner: "busches") {
        pullRequests(states: OPEN) {
          totalCount
        }
        refs(refPrefix: "refs/heads/", first: 100) {
          nodes {
            associatedPullRequests(states: OPEN, first: 100) {
              nodes {
                isCrossRepository
              }
            }
          }
        }
      }
    }
    
  8. fregante commented on Dec 6, 2019

    @fregante
    MemberAuthor

    No you don’t need to query it from the API because the number is already in the tab itself, right?

  9. dertieran commented on Dec 6, 2019

    @dertieran
    Contributor

    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.

  10. loilo commented on Mar 10, 2020

    @loilo
    Contributor

    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):

    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:

    Head area of the loilo/mautic repo with the secondary headline stating "forked from mautic/mautic with 1 open PR" with the "1 open PR" part as a link

    What do you think?

  11. fregante commented on Mar 10, 2020

    @fregante
    MemberAuthor

    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.

  12. loilo commented on Mar 10, 2020

    @loilo
    Contributor

    Good point. I'll try to figure it out.

  13. issuehunt-oss commented on Mar 31, 2020

    @issuehunt-oss

    @sindresorhus has rewarded $4.50 to @loilo. See it on IssueHunt

    • 💰 Total deposit: $5.00
    • 🎉 Repository reward(0%): $0.00
    • 🔧 Service fee(10%): $0.50
  14. added and removed
    💵 Funded on Issuehunt
    on Mar 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions