sindresorhus/refined-github

Add contributor's repository address to pull request pages. #3578

shepmaster posted onGitHub

As a maintainer, I sometimes need to push changes to contributor's PRs. The nature of my projects means that I get many one-off submissions from new contributors.

Right now, I have to click on the user's repo link:

image

Then open the repo dropdown and copy the link:

image

Honestly, I don't know that I've ever had a usage for the clipboard icon on the PR (which copies username/branchname).

Instead, it would be nice to short-circuit that and allow copying the contributor's repository address directly from the PR. Either by repeating the green dropdown or by just copying the SSH address (since I need to be authenticated to push to the branch).

Example URL: https://github.com/shepmaster/snafu/pull/251 (any pull request).

Thanks so much for an awesome project!


There's https://github.com/github/hub and https://github.com/cli/cli trying to solve this for checking out using PR numbers, but as someone who uses plain git and SSH based auth, I feel your pain.

posted by notlmn over 4 years ago

There's already a number of ways to accomplish this:

Honestly, I don't know that I've ever had a usage for the clipboard icon on the PR (which copies username/branchname).

We agree šŸ™Œ

someone who uses plain git and SSH based auth, I feel your pain

Why? What's stopping you from installing gh-cli?

posted by fregante over 4 years ago

We could however, if there's a good reason to, split that link in 2 parts like:

But it feels like it's gonna break the copy button and it might not be worth it

posted by fregante over 4 years ago

Why? What's stopping you from installing gh-cli?

  • An SSD which I recently got
  • Heavy git muscle memory if I wanted to switch to hub
  • The idea of using another tool only to checkout PRs
posted by notlmn over 4 years ago

for checking out using PR numbers

Ah, sorry for not clarifying this better. I actually already have something for that so I can type git pr NNNNN and it downloads and checks out the branch:

[alias]
    pr = "!f() { git fetch -fu upstream refs/pull/$1/head:pr/$1; git checkout pr/$1; } ; f"

The problem comes when I need to push changes to the PR, which requires me to push to the authors branch, AFAIK:

Add more commits by pushing to the patch-1 branch on Henning-K/snafu.

Specifically, I need to run this first command (and ideally some variant of the second):

git remote add Henning-K git@github.com:Henning-K/snafu.git
git checkout Henning-K/patch-1

The first command requires the repository address.

After some work, I then run some variant of

git push Henning-K +patch-1
posted by shepmaster over 4 years ago

someone who uses plain git and SSH based auth, I feel your pain

@notlmn So you still prefer manually selecting the source repo and all that (hence the pain) instead of just setting up a new tool. It's not like gh is larger than a few megs, it's not Electron like GitHub Desktop šŸ˜„

posted by fregante over 4 years ago

@notlmn So you still prefer manually selecting the source repo and all that (hence the pain) instead of just setting up a new tool. It's not like gh is larger than a few megs, it's not Electron like GitHub Desktop šŸ˜„

I have 2FA setup on my GitHub account, which requires me to either do token based authentication (a pain in the ass, and nasty overall), or setup SSH (easy, no password required, but cloning/checking out PRs is a pain).

Regular cloning with both hub and gh set remote to https://... (tried setting git_protocol to ssh that doesn't work too). But for any form of pushes, you require SSH-based auth, which would not work if the remote is in the form https://....

Which is what @shepmaster is trying to explain in their [alias] example, pull works either with https:// or git@ protocols, but you will have to add remote as git@ for push to work.

Apologies for the very bad explanation, correct me if I'm wrong wherever possible.

posted by notlmn over 4 years ago

I also have 2FA but I don't see how the token is nasty. I set it up months ago and it's painless šŸ˜… It's a once-in-a-(computer-)lifetime configuration versus manually setting up origins for every repo I work on.

posted by fregante over 4 years ago

@fregante you may be addressing my original issue, but I'm at a loss for how. Are you stating that one of

  • GitHub Desktop
  • GH cli
  • HUB cli

Allows me to go from a PR number / URL to adding the remote that the PR comes from so that I can push to that remote? I don't mean solely checking out a PR locally, nor do I mean cloning the repository that the PR is being submitted to. As mentioned earlier I already have a solution for that by itself.

posted by shepmaster over 4 years ago

I'm at a loss, too, I just tried with hub and it doesn't automatically also set a remote like this cheatsheet suggests and I assumed that this new gh tool was actually useful.

So, yeah. @sindresorhus how do you check out PRs while also setting their remote?

I've been ignorant of the whole process because GitHub Desktop does with certainty allow pushes with extreme ease:

āÆ git clone https://github.com/sindresorhus/refined-github.git
Resolving deltas: 100% (11615/11615), done.
āÆ cd refined-github/
āÆ github .

<img width="672" alt="" src="https://user-images.githubusercontent.com/1402241/93816992-e2f24200-fc1d-11ea-92ed-b9d6bf5c06bc.png">

āÆ git remote
github-desktop-yashshah1
origin
posted by fregante over 4 years ago

Kinda makes me want to bring proper git-based instructions for everyone, adding a third tab here:

<img width="327" alt="" src="https://user-images.githubusercontent.com/1402241/93817416-8b080b00-fc1e-11ea-878f-0adab0d826fc.png">

Perhaps we should reopen https://github.com/sindresorhus/refined-github/issues/2767 instead.

posted by fregante over 4 years ago

Closing in favor of #2767, which tackles the issue directly.

posted by fregante over 4 years ago

Fund this Issue

$0.00
Funded

Pull requests