diff --git a/git-open b/git-open index a367db6..f15eb0d 100755 --- a/git-open +++ b/git-open @@ -157,6 +157,15 @@ else fi fi +# Normalize known SSH host aliases to their web URL hosts. +# These are the SSH-over-HTTPS endpoints used when port 22 is blocked, +# and their web URLs live on the regular domains. +# e.g. git@ssh.github.com:owner/repo.git should open https://github.com/owner/repo +case $domain in + ssh.github.com) domain='github.com' ;; + altssh.gitlab.com) domain='gitlab.com' ;; +esac + # Trim "/" from beginning of URL; "/" and ".git" from end of URL urlpath=${urlpath#/} urlpath=${urlpath%/} urlpath=${urlpath%.git} diff --git a/test/git-open.bats b/test/git-open.bats index e891be5..6baa2aa 100755 --- a/test/git-open.bats +++ b/test/git-open.bats @@ -137,6 +137,24 @@ setup() { assert_output "https://github.com/user/repo" } +@test "gh: ssh-over-443 endpoint (ssh.github.com) with scp-like syntax" { + git remote set-url origin "git@ssh.github.com:user/repo.git" + run ../git-open + assert_output "https://github.com/user/repo" +} + +@test "gh: ssh-over-443 endpoint (ssh://git@ssh.github.com:443)" { + git remote set-url origin "ssh://git@ssh.github.com:443/user/repo.git" + run ../git-open + assert_output "https://github.com/user/repo" +} + +@test "gitlab: ssh-over-443 endpoint (altssh.gitlab.com)" { + git remote set-url origin "ssh://git@altssh.gitlab.com:443/user/repo.git" + run ../git-open + assert_output "https://gitlab.com/user/repo" +} + @test "gh: git protocol origin" { git remote set-url origin "git://github.com/user/repo.git" git checkout -B "master"