Skip to content

Commit

Permalink
Evaluate symlink when detecting gitRelDir (#452)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Couture-Beil <alex@earthly.dev>
  • Loading branch information
alexcb and alexcb committed Oct 27, 2020
1 parent 50ddcba commit f627840
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion buildcontext/detectgit.go
Expand Up @@ -232,11 +232,15 @@ func gitRelDir(basePath string, path string) (string, bool, error) {
if err != nil {
return "", false, errors.Wrapf(err, "get abs path for %s", path)
}
absPath2, err := filepath.EvalSymlinks(absPath)
if err != nil {
return "", false, errors.Wrapf(err, "eval symlinks for %s", absPath)
}
if !filepath.IsAbs(basePath) {
return "", false, fmt.Errorf("Git base path %s is not absolute", basePath)
}
basePathSlash := filepath.ToSlash(basePath)
pathSlash := filepath.ToSlash(absPath)
pathSlash := filepath.ToSlash(absPath2)
basePathParts := strings.Split(basePathSlash, "/")
pathParts := strings.Split(pathSlash, "/")
if len(pathParts) < len(basePathParts) {
Expand Down

0 comments on commit f627840

Please sign in to comment.