Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Git SSH support #31

Closed
hugomd opened this issue Feb 1, 2017 · 17 comments
Closed

Git SSH support #31

hugomd opened this issue Feb 1, 2017 · 17 comments

Comments

@hugomd
Copy link

hugomd commented Feb 1, 2017

It would be nice if clicking the branch name took you to the branch if the remote is git via SSH rather than HTTPS.

@henrikruscon
Copy link
Owner

henrikruscon commented Feb 4, 2017

@hugomd could you elaborate? ✌️

@hugomd
Copy link
Author

hugomd commented Feb 4, 2017

@henrikdahl If I cd into a git repository, the bottom right hand corner gives a link to the branch I'm on:

This works fine if I've cloned using HTTPS, and opens my browser and takes me to the repository. If I've cloned using SSH then it opens a new terminal window rather than opening the browser.

@henrikruscon
Copy link
Owner

@hugomd are you saying it currently opens a new terminal window when you've cloned with SSH or that it's the expected behavior you'd like to see?

@hugomd
Copy link
Author

hugomd commented Feb 5, 2017

@henrikdahl It opens a new terminal window when I've cloned with SSH and click on master, but it would be great if it could open the repository in the default browser — not sure if that's feasible or not though.

@henrikruscon
Copy link
Owner

@hugomd mind sharing how your remote url looks?

@henrikruscon
Copy link
Owner

It should already do what you're suggesting, which is why it would be useful to see what your remote url looks like. I'm closing this for now ✌️

@hugomd
Copy link
Author

hugomd commented Feb 14, 2017

@henrikdahl Totally missed this, sorry! It seems to work for GitHub, but not GitLab — I'll look into it myself and see if I can work it out myself and maybe make a PR.

@hugomd
Copy link
Author

hugomd commented Feb 14, 2017

@henrikdahl Found it. Issue is caused by L167.

If the git remote uses any port other than 22 it won't work. E.g.

> remote = "ssh://git@git.hu.md:1022/hugo/dotfiles.git";
'ssh://git@my.hosted.git:1022/hugo/myrepo.git'
> curRemote = remote.trim().replace(/^git@(.*?):/, 'https://$1/').replace(/[A-z0-9\-]+@/, '').replace(/\.git$/, '');
'ssh://my.hosted.git:1022/hugo/myrepo'

Expected output should be:
https://my.hosted.git/hugo/myrepo
Output causing issue is currently:
ssh://my.hosted.git:1022/hugo/myrepo

@henrikruscon
Copy link
Owner

henrikruscon commented Feb 15, 2017

How come your remote includes ssh://? It should work without it and GitLab doesn't add it by default.

Input
skarmavbild 2017-02-15 kl 02 54 11

Output
skarmavbild 2017-02-15 kl 02 54 30

Although you're right about the port, I'll have to update the regex for that, I didn't consider it when I wrote it ✌️

@hugomd
Copy link
Author

hugomd commented Feb 15, 2017

I'm running a self-hosted instance of GitLab, which uses a different port. When you do that, GitLab pops ssh:// in front of it.

@henrikruscon
Copy link
Owner

So I'm not sure how to solve this. ssh:// part is easy since the regex can simply check for any character before the @ symbol instead of specifically git.

However the port part is identical to the username part.

ssh://git@my.hosted.git:1022/hugo/myrepo.git
git@github.com:henrikdahl/hyper-statusline.git

Since a username can be numbers as well, there's really no way to identify which it is. Any suggestion for a pattern thats consistent? ✌️

@hugomd
Copy link
Author

hugomd commented Feb 15, 2017

You could check to see if it starts with ssh://, and if it does then remove what's immediately after the ssh://git@my.hosted.git:

There might be a simpler way though

@henrikruscon
Copy link
Owner

Someone could have ssh:// even though they don't have a port, it would mess up their URLs so it's not fully reliable.

@hugomd
Copy link
Author

hugomd commented Feb 15, 2017

@henrikdahl That's true — I'm not sure how I'd recommend fixing it then. I'll try changing my GitLab port to 22 for now! 👍

Thanks for dealing with the issue!

@hugomd
Copy link
Author

hugomd commented Feb 15, 2017

@henrikdahl Is the port always followed by a /? If so you could regex select a number followed by a /, while still allowing the previous usage.

@henrikruscon
Copy link
Owner

@hugomd Problem is that a username could be numbers and follow the exact same pattern.

@hugomd
Copy link
Author

hugomd commented Feb 15, 2017

@henrikdahl I understand that but / isn't allowed in usernames, and separates the two.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants