Vscode-gitlens: Implement an easy way to add a new remotes.

Created on 1 Apr 2019  路  8Comments  路  Source: eamodio/vscode-gitlens

As I brought up in https://github.com/eamodio/vscode-gitlens/issues/612#issuecomment-477242751 it would be nice to be able to just right-click on remotes in gitlens side panel and see a menu item for Add new remote. Currently there's only an entry for Refresh.

GitLens_Remotes

For now I've resorted to following this guide from github to add upstream remote from vsc terminal:
https://help.github.com/en/articles/configuring-a-remote-for-a-fork

It certainly works, however it does feel a bit dissatisfying having to resort to using the terminal for this, what with everything else one can do through GitLens already. I certainly think that the proposed feature fits the overall design of GitLens well.

good-first-issue help-wanted feature

Most helpful comment

Added in v9.93 -- thanks @zaboyle!

All 8 comments

I'm new to open source, but I'm working on implementing a feature like this! Hope to make a PR in the near future

@zaboyle awesome! Please let me know if you have any questions. And don't hesitate to open a PR early.

Hi @eamodio ! I actually do have a question: I think i found a resource on this website to help with creating the "Add Remote" option that should appear when right-clicking, but I am having trouble figuring out how to create a Command object for this Git command. If you can point me in the right direction, I would greatly appreciate it!

So there a quite a few steps to this, but I'll try to lay out the basics and will use the gitlens.views.checkout command as the "template" to follow.

So first you'll need to add a new command for gitlens.views.addRemote similar to gitlens.views.checkout
https://github.com/eamodio/vscode-gitlens/blob/345be49d7b31f8dfd8cf2f60fadee0bc2fed17d3/package.json#L2367-L2376

Then you add a "placement" for the command like below, but it should be gitlens.remotes rather than gitlens.branch
https://github.com/eamodio/vscode-gitlens/blob/345be49d7b31f8dfd8cf2f60fadee0bc2fed17d3/package.json#L4255-L4260

Then you register a callback for when the command is executed, like:
https://github.com/eamodio/vscode-gitlens/blob/345be49d7b31f8dfd8cf2f60fadee0bc2fed17d3/src/views/viewCommands.ts#L116-L117

And then implement a new addRemote method

That is the basics of it.

Awesome, thank you for your help! I'll work on that today and this weekend :thumbsup:

Thanks again for your help @eamodio ! I made a PR for this in #802 , let me know if there's anything I need to change!

Added in v9.93 -- thanks @zaboyle!

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings