fix: remote taskfiles from ADO git path (#2904)

This commit is contained in:
Pete Davison
2026-07-01 13:38:38 +01:00
committed by GitHub
parent 6cf0303ab8
commit a6cedbe732
2 changed files with 8 additions and 1 deletions

View File

@@ -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
}

View File

@@ -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)
}