Check for explicit ssh git URL
- fix IsSSHTransport to also check for explicitly-defined ssh-based git repos Signed-off-by: Alex Couture-Beil <alex@earthly.dev>v0.9
parent
7880a4ea24
commit
0dff0fdab4
|
@ -2,10 +2,17 @@ package sshutil
|
|||
|
||||
import (
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var gitSSHRegex = regexp.MustCompile("^[a-zA-Z0-9-_]+@[a-zA-Z0-9-.]+:.*$")
|
||||
|
||||
func IsSSHTransport(s string) bool {
|
||||
// check for explicit ssh transport
|
||||
if strings.HasPrefix(s, "ssh://") {
|
||||
return true
|
||||
}
|
||||
|
||||
// check for implicit ssh transport
|
||||
return gitSSHRegex.MatchString(s)
|
||||
}
|
||||
|
|
|
@ -20,4 +20,5 @@ func TestIsSSHTransport(t *testing.T) {
|
|||
require.True(t, IsSSHTransport("other_Funky-username52@example.com:path/to/repo.git/"))
|
||||
require.True(t, IsSSHTransport("other_Funky-username52@example.com:/to/really:odd:repo.git/"))
|
||||
require.True(t, IsSSHTransport("teddy@4houses-down.com:/~/catnip.git/"))
|
||||
require.True(t, IsSSHTransport("ssh://root@subdomain.example.hostname:2222/root/my/really/weird/path/foo.git"))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue