mirror of
https://github.com/go-task/task.git
synced 2026-07-03 01:18:48 +00:00
fix: remote taskfiles from ADO git path (#2904)
This commit is contained in:
@@ -2,6 +2,7 @@ package taskfile
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -89,7 +90,10 @@ func getScheme(uri string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if strings.HasSuffix(strings.Split(u.Path, "//")[0], ".git") && (u.Scheme == "git" || u.Scheme == "ssh" || u.Scheme == "https" || u.Scheme == "http") {
|
||||
isDotGit := strings.HasSuffix(strings.Split(u.Path, "//")[0], ".git")
|
||||
isUnderscoreGit := strings.Contains(strings.Split(u.Path, "//")[0], "/_git/")
|
||||
schemeIsGitCompatible := slices.Contains([]string{"git", "ssh", "https", "http"}, u.Scheme)
|
||||
if (isDotGit || isUnderscoreGit) && schemeIsGitCompatible {
|
||||
return "git", nil
|
||||
}
|
||||
|
||||
|
||||
@@ -21,4 +21,7 @@ func TestScheme(t *testing.T) {
|
||||
scheme, err = getScheme("https://github.com/foo/common.yml")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "https", scheme)
|
||||
scheme, err = getScheme("https://some-azure-host.com/org/project/_git/repo")
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, "git", scheme)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user