ben-gibson / GitLink

A Jetbrains plugin that opens a local file under Git version control in its remote host using the default browser.
https://plugins.jetbrains.com/plugin/8183-gitlink
MIT License
671 stars 58 forks source link

Host association compatibility with ".ssh/config" #293

Open CiottiGiorgio opened 1 year ago

CiottiGiorgio commented 1 year ago

When using different ssh keys associated to different profiles, it's usually the norm that people configure their .ssh/config file like so:

Host dev
    HostName dev.example.com
    User john
    Port 2322

Making it such that if the repo is cloned using: git clone dev:org/project.git

The dev hostname is not correctly resolved and has to be set manually. This is not a big inconvenience but it would be nice if GitLink is able to parse the config file and understand the real platform that a particular ssh profile/key is being used for.

Vistritium commented 1 year ago

Reading the correct host from config might be some effort, but if we could at least just override the hostname per project that would be already great. Right now it uses wrong hostname and there is nothing I can do about it, just have to replace it manually every time.

Edit: actually there is a workaround. I created another origin, called it "real" and told gitlink to use this origin, now it works.

kfirfer commented 6 months ago

I have the same problem(kinda) when I cloned through ssh instead https and also configured the .ssh/config to have 2 different ssh keys with the same git vendor (gitlab in the following example):

.ssh/config:

Host gitlab.com
  HostName gitlab.com
  User git
  IdentityFile ~/.ssh/id_rsa_gitlab_fuzzyme

Host gitlab.com-kfirfer
  HostName gitlab.com
  User git
  IdentityFile ~/.ssh/id_rsa_gitlab_kfirfer

the plugin uses Host gitlab.com-kfirfer (git remote -v) and got bad url + no auto detect its frasturating even if we need to go through manual process to change all repositories

will be great if we could globally configure the plugin to delete prefix/suffix from the Host From exampled above, if we could configure to delete the suffix -kfirfer , the plugin could reach gitlab.com

ben-gibson commented 6 months ago

Having a hostname override option in the plugin settings would be the easiest solution for this as @Vistritium suggested. This could be a simple input box in the project level settings or a map option at the application level that lets you specify multiple hosts, for example, gitlab.com-kfirfer => gitlab.com