sindresorhus/refined-github

Do you want to work on this issue?

You can request for a bounty in order to promote it!

`git-checkout-pr` should also work in closed PR #4701

kidonng posted onGitHub

Description

It seems the exclusion is due to implementation problem: ee2d9e6 (#3596)

I agree it would be rare, but chances are people need to checkout a closed PR in order to test it, base their work on it or whatever. GitHub doesn't hide the "Code" dropdown on closed PR so I think we shouldn't either.

Screenshot

No response

Example URL

https://github.com/sindresorhus/refined-github/pull/3759


I agree it would be rare,

Thats why it should not be enabled also the branch would be deleted.

posted by yakov116 over 3 years ago

also the branch would be deleted.

A PR can stay open if the forked repo is deleted. Do this feature handle that?

When I'm posting this I was wondering if it is better implemented with:

git config --add remote.origin.fetch "+refs/pull/<pr number>/head:refs/remotes/origin/pr/<pr number>"
git pull origin
git switch --track origin/pr/<pr number>

...which works even if the branch is gone:

$ git clone https://github.com/sindresorhus/refined-github
Cloning into 'refined-github'...
remote: Enumerating objects: 19495, done.
remote: Counting objects: 100% (259/259), done.
remote: Compressing objects: 100% (159/159), done.
remote: Total 19495 (delta 133), reused 192 (delta 97), pack-reused 19236
Receiving objects: 100% (19495/19495), 16.90 MiB | 7.49 MiB/s, done.
Resolving deltas: 100% (14848/14848), done.

$ cd refined-github/

$ git config --add remote.origin.fetch "+refs/pull/4554/head:refs/remotes/origin/pr/4554"

$ git pull origin
remote: Enumerating objects: 29, done.
remote: Counting objects: 100% (23/23), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 29 (delta 20), reused 16 (delta 16), pack-reused 6
Unpacking objects: 100% (29/29), 6.75 KiB | 256.00 KiB/s, done.
From https://github.com/sindresorhus/refined-github
 * [new ref]           refs/pull/4554/head -> origin/pr/4554
Already up to date.

$ git switch --track origin/pr/4554
Branch 'pr/4554' set up to track remote branch 'pr/4554' from 'origin'.
Switched to a new branch 'pr/4554'
posted by kidonng over 3 years ago
git config --add remote.origin.fetch "+refs/pull/<pr number>/head:refs/remotes/origin/pr/<pr number>"
git pull origin
git switch --track origin/pr/<pr number>

Like!

posted by yakov116 over 3 years ago

I know why we did not do that, since for maintainers/owners we want to keep the same branch name.

posted by yakov116 over 3 years ago
```shell
git config --add remote.origin.fetch "+refs/pull/<pr number>/head:refs/remotes/origin/pr/<pr number>"
git pull origin
git switch --track origin/pr/<pr number>

Like!

Let's ensure it's pushable. We had some constraints when looking for the best/shortest commands, specifically to ensure that pushing also works (and maybe more). @kidonng refer to the original issue and PR.

Regarding this feature request, it makes sense for the simple reason that GitHub includes the Code dropdown on closed PRs too, so we should handle it the same way.

posted by fregante over 3 years ago

I know why we did not do that, since for maintainers/owners we want to keep the same branch name.

I think you can specify the name in git switch and after all we have git branch --move.

Let's ensure it's pushable. We had some constraints when looking for the best/shortest commands, specifically to ensure that pushing also works (and maybe more). @kidonng refer to the original issue and PR.

It should be since GitHub's official CLI works this way, haven't test it though.

Regarding this feature request, it makes sense for the simple reason that GitHub includes the Code dropdown on closed PRs too, so we should handle it the same way.

Yeah that's the motivation for this issue, really confusing why it doesn't work and I nearly created a bug report for that. 😅

posted by kidonng over 3 years ago

Fund this Issue

$0.00
Funded
Only logged in users can fund an issue

Pull requests