mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 05:31:47 +00:00
Allow git@ prefixes for any hosted git service
Signed-off-by: Aidan Hobson Sayers <aidanhs@cantab.net>
This commit is contained in:
+1
-1
@@ -293,7 +293,7 @@ func IsURL(str string) bool {
|
||||
}
|
||||
|
||||
func IsGIT(str string) bool {
|
||||
return strings.HasPrefix(str, "git://") || strings.HasPrefix(str, "github.com/") || strings.HasPrefix(str, "git@github.com:") || (strings.HasSuffix(str, ".git") && IsURL(str))
|
||||
return strings.HasPrefix(str, "git://") || strings.HasPrefix(str, "github.com/") || strings.HasPrefix(str, "git@") || (strings.HasSuffix(str, ".git") && IsURL(str))
|
||||
}
|
||||
|
||||
func ValidGitTransport(str string) bool {
|
||||
|
||||
+25
-6
@@ -98,23 +98,42 @@ func TestReadSymlinkedDirectoryToFile(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidGitTransport(t *testing.T) {
|
||||
for _, url := range []string{
|
||||
var (
|
||||
gitUrls = []string{
|
||||
"git://github.com/docker/docker",
|
||||
"git@github.com:docker/docker.git",
|
||||
"git@bitbucket.org:atlassianlabs/atlassian-docker.git",
|
||||
"https://github.com/docker/docker.git",
|
||||
"http://github.com/docker/docker.git",
|
||||
} {
|
||||
}
|
||||
incompleteGitUrls = []string{
|
||||
"github.com/docker/docker",
|
||||
}
|
||||
)
|
||||
|
||||
func TestValidGitTransport(t *testing.T) {
|
||||
for _, url := range gitUrls {
|
||||
if ValidGitTransport(url) == false {
|
||||
t.Fatalf("%q should be detected as valid Git prefix", url)
|
||||
}
|
||||
}
|
||||
|
||||
for _, url := range []string{
|
||||
"github.com/docker/docker",
|
||||
} {
|
||||
for _, url := range incompleteGitUrls {
|
||||
if ValidGitTransport(url) == true {
|
||||
t.Fatalf("%q should not be detected as valid Git prefix", url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsGIT(t *testing.T) {
|
||||
for _, url := range gitUrls {
|
||||
if IsGIT(url) == false {
|
||||
t.Fatalf("%q should be detected as valid Git url", url)
|
||||
}
|
||||
}
|
||||
for _, url := range incompleteGitUrls {
|
||||
if IsGIT(url) == false {
|
||||
t.Fatalf("%q should be detected as valid Git url", url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user