From ac027a8d00cc0469570aab423e142684388eee97 Mon Sep 17 00:00:00 2001 From: Andreas Schoeneck Date: Thu, 1 Jun 2017 12:38:04 +0200 Subject: [PATCH] Normalize ssh+port URLs to match default style This will make `ssh://git@://` URLs intermediately look like `git@:/` and expose these to further processing/substitution. Properties required for proper working are: * `gitopen.gitlab.domain` * `gitopen.gitlab.ssh.port` --- git-open | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/git-open b/git-open index 806a80e..db8ab52 100755 --- a/git-open +++ b/git-open @@ -110,19 +110,25 @@ else if [ -n "$gitlab_domain" ]; then if egrep -q "${gitlab_domain}|${gitlab_ssh_domain}" <<<"$giturl"; then + # bring it into the default notation + # handle SSH protocol (links like ssh://git@gitlab.domain.com/user/repo) + giturl=${giturl/#ssh\:\/\//} + + # remove SSH port + if [ -n "$gitlab_ssh_port" ]; then + giturl=${giturl/\:${gitlab_ssh_port}/} + fi + + # replace slash following domain with colon + giturl=${giturl/${gitlab_ssh_domain}\//${gitlab_ssh_domain}\:} + # Handle GitLab's default SSH notation (like git@gitlab.domain.com:user/repo) giturl=${giturl/git\@${gitlab_ssh_domain}\:/${gitlab_protocol}://${gitlab_domain}/} - # handle SSH protocol (links like ssh://git@gitlab.domain.com/user/repo) - giturl=${giturl/#ssh\:\/\//${gitlab_protocol}://} # remove git@ from the domain giturl=${giturl/git\@${gitlab_ssh_domain}/${gitlab_domain}/} - # remove SSH port - if [ -n "$gitlab_ssh_port" ]; then - giturl=${giturl/\/:${gitlab_ssh_port}\///} - fi providerUrlDifference=tree fi # hosted GitLab @@ -131,6 +137,7 @@ if [ -n "$gitlab_domain" ]; then providerUrlDifference=tree fi fi + giturl=${giturl%\.git} if [ -n "$issue" ]; then