Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions git-open
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down
18 changes: 18 additions & 0 deletions test/git-open.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down