1
0
mirror of https://github.com/go-task/task.git synced 2026-04-24 19:54:16 +02:00

fix: address "taskfile not found" in some environments like docker (#2709)

This commit is contained in:
Timothy Rule
2026-02-27 13:47:59 +01:00
committed by GitHub
parent 60a808ca23
commit 90bcbe9ba5
+12 -9
View File
@@ -153,13 +153,16 @@ func SearchPath(path string, possibleFilenames []string) (string, error) {
// also check if the user ID of the directory changes and abort if it does.
func SearchPathRecursively(path string, possibleFilenames []string) (string, error) {
paths, err := SearchNPathRecursively(path, possibleFilenames, 1)
if err != nil {
return "", err
if len(paths) > 0 {
// Regardless of the error, return the first possible filename.
return paths[0], nil
} else {
if err != nil {
return "", err
} else {
return "", os.ErrNotExist
}
}
if len(paths) == 0 {
return "", os.ErrNotExist
}
return paths[0], nil
}
// SearchNPathRecursively walks up the directory tree starting at the given
@@ -191,10 +194,10 @@ func SearchNPathRecursively(path string, possibleFilenames []string, n int) ([]s
// If the user id of the directory changes indicate a permission error, otherwise
// the calling code will infer an error condition based on the accumulated
// contents of paths.
if parentOwner != owner {
return paths, os.ErrPermission
} else if path == parentPath {
if path == parentPath {
return paths, nil
} else if parentOwner != owner {
return paths, os.ErrPermission
}
owner = parentOwner