From 6f07f14de515634da3bc250387f0c4b1271c27e9 Mon Sep 17 00:00:00 2001 From: Liam Potter Date: Mon, 15 Aug 2016 13:19:17 +0100 Subject: [PATCH] Handle gitlab using SSH remote URL You need to add another config option to remove the port, but this is now working for me. Could be improved by adding an option for the protocol as well, I'm using `http` instead of `https`, I've left that as is for now though. --- git-open | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/git-open b/git-open index 160be37..a852c30 100755 --- a/git-open +++ b/git-open @@ -92,9 +92,20 @@ elif grep -q "/scm/" <<<$giturl; then else # custom GitLab gitlab_domain=$(git config --get gitopen.gitlab.domain) + gitlab_port=$(git config --get gitopen.gitlab.port) if [ -n "$gitlab_domain" ]; then if grep -q "$gitlab_domain" <<<$giturl; then - giturl=${giturl/git\@${gitlab_domain}:/https://${gitlab_domain}/} + + # handle SSH protocol (links like ssh://git@gitlab.domain.com/user/repo) + giturl=${giturl/#ssh\:\/\//https://} + + # remove git@ from the domain + giturl=${giturl/git\@${gitlab_domain}/${gitlab_domain}/} + + # remove SSH port + if [ -n "$gitlab_port" ]; then + giturl=${giturl/\/:${gitlab_port}\///} + fi providerUrlDifference=tree fi # hosted GitLab