-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: add fork remote command #4831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: add fork remote command #4831
Conversation
The command allows you to quickly add a new 'fork' remote with replaced owner in the origin URL of the selected remote. For example: given url: https://github.com/jesseduffield/lazygit.git and username: karolzwolak adds a new remote with url: https://github.com/karolzwolak/lazygit.git
Yes, that's a great follow-up. It should be easy to do, too. I will implement it.
Yeah, I might have gone overboard with the url parsing. I didn't know we had regex support. Regex would work well for ssh urls, but it's a bit more nuanced for http/https urls, but I'll try to simplify it.
I also don't have experience besides github, but I think most other hosting services follow the same owner/repo url pattern as github does, so it should work fine without any further modifications. I might be wrong on this, though. I'm away from home for about 2 weeks, so I won't be active on this right now. |
I've refactored the replacement to just use regex replace. I think your suggestion is great follow up, but I think it should be supported not just in this new add fork feature, but also when adding a general remote like @stefanhaller friendly ping |
ffd365b
to
d74c08d
Compare
Nevermind, I added the ability to checkout PRs with |
d74c08d
to
651ee12
Compare
Still didn't look at the code very much, but tested the feature, and it works nicely. One thing I'm wondering is whether we need the second prompt that asks for a remote name; in my own use, I always use the same name as the forkUsername, doesn't everybody? And then, I was also wondering if this even needs to be a separate command at all. We could include the functionality in the normal "add new remote" command, where the first prompt would say |
Not always. I often add my own fork as origin or the main repo as upstream. But if we ditched the name prompt, I guess I could just rename the remote after creating it.
Incorporating it into add remote sounds nice in theory, but I’m not sure it works as well in practice. You still end up with two prompts and some limits:
It also gets tricky if there’s no origin or multiple remotes. I think incorporating it this way would be too clunky. Dedicated command feels clearer, more powerful, and would allow more flexibility. I'm open to other suggestions for improving this new feature. |
I have used this for a while in my local build now, and I quite like it. I'm happy to keep it as a separate command; after thinking about it more, my suggestion to incorporate it into the add remote command wasn't so good. However, I still can't get used to the second prompt, and I still vote for getting rid of it. The only scenarios I can imagine where you would want a different remote name is either origin itself (but that's irrelevant here), or an "upstream" remote. For that, I'd imagine you would use the regular add remote command; or rename it afterwards. Since that's a one-time thing, I don't find that too bad. But in all other cases the additional prompt is simply confusing, it trips me up every time. Apart from that, I was thinking if we should have any special handling of the case that a remote with that name already exists; currently you get an error popup, which I guess is appropriate, but I was thinking it might be nice if I didn't have to pay attention and it would just use the existing remote and only check out the branch. But maybe that's too much magic and we just keep it the way it is. |
PR Description
The command allows you to quickly add a new 'fork' remote with
replaced owner in the origin URL of the selected remote.
For example:
given url: https://github.com/jesseduffield/lazygit.git
and username: karolzwolak
adds a new remote with url: https://github.com/karolzwolak/lazygit.git
Please check if the PR fulfills these requirements
go generate ./...
)clip.mp4