diff --git a/builder/remotecontext/git/gitutils.go b/builder/remotecontext/git/gitutils.go index 8c39d33c667e309140116bc81db47e298511f9b9..ffd5123798f6d92317a20dbe90f40513733d80de 100644 --- a/builder/remotecontext/git/gitutils.go +++ b/builder/remotecontext/git/gitutils.go @@ -209,7 +209,7 @@ func isGitTransport(str string) bool { } switch getScheme(str) { - case "git", "http", "https": + case "git", "http", "https", "ssh": return true } diff --git a/builder/remotecontext/git/gitutils_test.go b/builder/remotecontext/git/gitutils_test.go index aa9e052474cf1f5fc23e8f7b1de62b35d53055b8..fbbe03076479348283a3e9e3535c72b5ff1d210a 100644 --- a/builder/remotecontext/git/gitutils_test.go +++ b/builder/remotecontext/git/gitutils_test.go @@ -83,6 +83,32 @@ func TestParseRemoteURL(t *testing.T) { subdir: "mydir/mysubdir/", }, }, + { + doc: "ssh, no url-fragment", + url: "ssh://github.com/user/repo.git", + expected: gitRepo{ + remote: "ssh://github.com/user/repo.git", + ref: "master", + }, + }, + { + doc: "ssh, with url-fragment", + url: "ssh://github.com/user/repo.git#mybranch:mydir/mysubdir/", + expected: gitRepo{ + remote: "ssh://github.com/user/repo.git", + ref: "mybranch", + subdir: "mydir/mysubdir/", + }, + }, + { + doc: "ssh, with url-fragment and user", + url: "ssh://foo%40barcorp.com@github.com/user/repo.git#mybranch:mydir/mysubdir/", + expected: gitRepo{ + remote: "ssh://foo%40barcorp.com@github.com/user/repo.git", + ref: "mybranch", + subdir: "mydir/mysubdir/", + }, + }, } for _, tc := range tests {