Skip to content

Show pull requests to source repo on fork's branch list #2914

Closed

Description

@Jackenmen

When some branch on the repo is a head of PR made to that repo, the PR is shown near the branch on branch list:
image

I think it would be great if branch list on forks also included the PRs that are made to their source repo so that user could figure out easily which branches can be removed.

Example URL:
https://github.com/jack1142/Red-DiscordBot/branches/all

Activity

  1. fregante commented on Mar 28, 2020

    @fregante
    Member

    This makes sense and indeed the existing Compare buttons do point to a page that links to the open PR already:

    compare

    It's just that for whatever reason GitHub doesn't show this information directly on the list.

    Does this information appear in the GraphQL API? If so, it could also be useful to find PRs opened from the current repo for #2934

  2. fregante commented on Mar 28, 2020

    @fregante
    Member

    Here:

    query { 
      repository(owner: "jack1142", name: "Red-DiscordBot") {
        refs(refPrefix: "refs/heads/", first: 100) {
          nodes {
            name
            associatedPullRequests(first: 100, states: OPEN) {
              nodes {
                number
                url
              }
            }
          }
        }
      }
    }
    {
      "data": {
        "repository": {
          "refs": {
            "nodes": [
              {
                "name": "V3/alias_non_existent_command",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "V3/allow_any_valid_locale",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3676,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3676"
                    }
                  ]
                }
              },
              {
                "name": "V3/bring_back_role_mention_sanitizer",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3625,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3625"
                    }
                  ]
                }
              },
              {
                "name": "V3/changelog_pr_labeler",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "V3/changelog_3.3.3",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3660,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3660"
                    }
                  ]
                }
              },
              {
                "name": "V3/develop",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "V3/feature/audio",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "V3/issue_2527",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "V3/issue_3200",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3200,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3200"
                    }
                  ]
                }
              },
              {
                "name": "V3/issue_3605",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3679,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3679"
                    }
                  ]
                }
              },
              {
                "name": "V3/regional_formatting",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3677,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3677"
                    }
                  ]
                }
              },
              {
                "name": "V3/restore_command",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3681,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3681"
                    }
                  ]
                }
              },
              {
                "name": "V3/some_fun_with_async_initialize",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "develop",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "jack1142-patch-1",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3649,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3649"
                    }
                  ]
                }
              },
              {
                "name": "jack1142-patch-2",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "jack1142-patch-5",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "jack1142-patch-6",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3672,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3672"
                    }
                  ]
                }
              },
              {
                "name": "patch-3",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3215,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3215"
                    }
                  ]
                }
              },
              {
                "name": "pr/ghactions",
                "associatedPullRequests": {
                  "nodes": []
                }
              }
            ]
          }
        }
      }
    }
  3. Jackenmen commented on Mar 28, 2020

    @Jackenmen
    ContributorAuthor

    Looks like it does include them:

    query { 
      repository(owner: "jack1142", name: "Red-DiscordBot") {
        refs(refPrefix: "refs/heads/", first: 100) {
          nodes {
            name
            associatedPullRequests(first: 100, states: OPEN) {
              nodes {
                number
                url
              }
            }
          }
        }
      }
    }
    {
      "data": {
        "repository": {
          "refs": {
            "nodes": [
              {
                "name": "V3/alias_non_existent_command",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "V3/allow_any_valid_locale",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3676,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3676"
                    }
                  ]
                }
              },
              {
                "name": "V3/bring_back_role_mention_sanitizer",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3625,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3625"
                    }
                  ]
                }
              },
              {
                "name": "V3/changelog_pr_labeler",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "V3/changelog_3.3.3",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3660,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3660"
                    }
                  ]
                }
              },
              {
                "name": "V3/develop",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "V3/feature/audio",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "V3/issue_2527",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "V3/issue_3200",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3200,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3200"
                    }
                  ]
                }
              },
              {
                "name": "V3/issue_3605",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3679,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3679"
                    }
                  ]
                }
              },
              {
                "name": "V3/regional_formatting",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3677,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3677"
                    }
                  ]
                }
              },
              {
                "name": "V3/restore_command",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3681,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3681"
                    }
                  ]
                }
              },
              {
                "name": "V3/some_fun_with_async_initialize",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "develop",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "jack1142-patch-1",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3649,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3649"
                    }
                  ]
                }
              },
              {
                "name": "jack1142-patch-2",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "jack1142-patch-5",
                "associatedPullRequests": {
                  "nodes": []
                }
              },
              {
                "name": "jack1142-patch-6",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3672,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3672"
                    }
                  ]
                }
              },
              {
                "name": "patch-3",
                "associatedPullRequests": {
                  "nodes": [
                    {
                      "number": 3215,
                      "url": "https://github.com/Cog-Creators/Red-DiscordBot/pull/3215"
                    }
                  ]
                }
              },
              {
                "name": "pr/ghactions",
                "associatedPullRequests": {
                  "nodes": []
                }
              }
            ]
          }
        }
      }
    }
  4. fregante commented on Mar 28, 2020

    @fregante
    Member

    Alternatively we can go the opposite way, like for #2934, and only query the source repo. This wouldn't support oneFork-to-manyForks PRs but that's pretty rare, I'd say.

    The results are shorter and to the point though:

    {
      search(
        first: 100,
        type: ISSUE,
        query: "repo:Cog-Creators/Red-DiscordBot is:pr is:open author:jack1142"
    	) {
        nodes {
          ... on PullRequest {
            number
            headRefName
          }
        }
      }
    }
    {
      "data": {
        "search": {
          "nodes": [
            {
              "number": 3681,
              "headRefName": "V3/restore_command"
            },
            {
              "number": 3679,
              "headRefName": "V3/issue_3605"
            },
            {
              "number": 3677,
              "headRefName": "V3/regional_formatting"
            },
            {
              "number": 3676,
              "headRefName": "V3/allow_any_valid_locale"
            },
            {
              "number": 3672,
              "headRefName": "jack1142-patch-6"
            },
            {
              "number": 3660,
              "headRefName": "V3/changelog_3.3.3"
            },
            {
              "number": 3649,
              "headRefName": "jack1142-patch-1"
            },
            {
              "number": 3625,
              "headRefName": "V3/bring_back_role_mention_sanitizer"
            },
            {
              "number": 3215,
              "headRefName": "patch-3"
            },
            {
              "number": 3200,
              "headRefName": "V3/issue_3200"
            }
          ]
        }
      }
    }
  5. Jackenmen commented on Mar 28, 2020

    @Jackenmen
    ContributorAuthor

    Actually one thing I just noticed with both, I think it would be better to do it like GH does and show all PRs, not just open ones.

  6. fregante commented on Apr 8, 2020

    @fregante
    Member

    Why all PRs? The point here is to highlight forks that you can/cannot delete, closed PRs don’t seem important for that.

  7. Jackenmen commented on Apr 8, 2020

    @Jackenmen
    ContributorAuthor

    The point here is to highlight forks that you can/cannot delete

    It's definitely not the point for me, I thought that for the case you're mentioning, there's already this feature:
    image

    Why all PRs?

    I can think of few reasons:
    a) GitHub shows associated PR on branch list no matter if it's closed, merged or open so I think it would be good if this feature were consistent with original behavior.
    b) not all branches are associated to a PR therefore you can't differentiate easily between branches that are part of closed or merged PR and branches that never had their PR
    c) seeing associated PR can serve as a better summary of the work done in the branch - at the very least you can see the title of PR when you hover on its number in branch list and that view also shows small part of description and PR's labels
    image
    That info can be useful even if the PR has already been merged or closed.
    d) if PR was just closed instead of getting merged, it's important to know that removing the branch can cause you losing your work. I'm sure there are plenty of cases when PR doesn't end up being merged

  8. fregante commented on Apr 8, 2020

    @fregante
    Member

    It's definitely not the point for me, I thought that for the case you're mentioning, there's already this feature:

    D'oh, I thought we were talking about that feature. Sorry!

    As long as we only show one PR per branch this should be ok, otherwise the layout breaks.

  9. fregante commented on Apr 8, 2020

    @fregante
    Member

    This could work:

    { 
      repository(owner: "jack1142", name: "Red-DiscordBot") {
        refs(refPrefix: "refs/heads/", last: 100) {
          nodes {
            name
            associatedPullRequests(last: 1, states: [CLOSED, OPEN]) {
              nodes {
                number
                url
              }
            }
          }
        }
      }
    }

    Ideally you'd query each of the visible branches instead but the query I tried didn't include closed PRs (I tried via repository.ref().associatedPullRequests() and repository().object().associatedPullRequests())

  10. yakov116 commented on Apr 17, 2020

    @yakov116
    Member

    Ideally you'd query each of the visible branches instead but the query I tried didn't include closed PRs (I tried via repository.ref().associatedPullRequests() and repository().object().associatedPullRequests())

    Can you explain what you had in mind with this comment?

    Also why are you limiting it to only closed and open states?

  11. fregante commented on Apr 17, 2020

    @fregante
    Member

    My last example just asks GitHub for the last 100 branches and their related PR. Ideally instead you'd ask GitHub just for the PRs that are currently on screen, like

    {
    	repository(...) {
    		branchA: ref('branchA') {
    			associatedPullRequests(...) {
    				...
    			}
    		}
    		branchB: ref('branchB') {
    			associatedPullRequests(...) {
    				...
    			}
    		}
    		...
    	}
    }

    But none of the queries I tried included closed/merged PRs; they only returned open PRs. If anyone finds a way to query branches this way AND their related PR (even if closed) it's preferable instead of my last example.

  12. fregante commented on Apr 17, 2020

    @fregante
    Member

    Also why are you limiting it to only closed and open states?

    Mistake. I meant open/closed/merged.

  13. yakov116 commented on Apr 19, 2020

    @yakov116
    Member

    @fregante

    {
      repository(owner: "yakov116", name: "refined-github") {
        console_errors: ref(qualifiedName: "console_errors") {
          associatedPullRequests(last: 1) {
            nodes {
              number
              state
            }
          }
        }
        clone_branch: ref(qualifiedName: "restore-clone-branch") {
          associatedPullRequests(last: 1) {
            nodes {
              number
              state
            }
          }
        }
      }
    }
    {
      "data": {
        "repository": {
          "console_errors": {
            "associatedPullRequests": {
              "nodes": [
                {
                  "number": 2956,
                  "state": "CLOSED"
                }
              ]
            }
          },
          "clone_branch": {
            "associatedPullRequests": {
              "nodes": [
                {
                  "number": 3000,
                  "state": "MERGED"
                }
              ]
            }
          }
        }
      }
    }

    Unless you had something else in mind.

    I would much rather do the last 100 PR's since any search will require a new request.
    i also think its safe to say that most people with a fork have less than 100 branches

    Edit: Showing that it works for merged

  14. Jackenmen commented on Apr 20, 2020

    @Jackenmen
    ContributorAuthor

    In that case, isn't it simpler to just do it like here?
    #2914 (comment)

  15. yakov116 commented on Apr 20, 2020

    @yakov116
    Member

    In that case, isn't it simpler to just do it like here?
    #2914 (comment)

    I learned the hard way; when @fregante says something, follow it. Have questions... ask later.

  16. fregante commented on Apr 20, 2020

    @fregante
    Member

    In that case, isn't it simpler to just do it like here?

    That works, but if the alternative option is possible the result is safer and lighter. If it’s not possible, then sure.

  17. fregante commented on Apr 20, 2020

    @fregante
    Member

    I would much rather do the last 100 PR's since any search will require a new request.
    i also think its safe to say that most people with a fork have less than 100 branches

    Maybe you’re right

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