Allow directory substrings in cycle check.

This commit is contained in:
Jeffrey Regan
2018-12-13 15:20:15 -08:00
parent bd83773a1e
commit 352ec69556
3 changed files with 41 additions and 2 deletions

View File

@@ -190,8 +190,9 @@ func newGitLoader(
// seenBefore tests whether the current or any previously
// visited root begins with the given path.
func (l *fileLoader) seenBefore(path string) error {
terminated := path + string(filepath.Separator)
for _, r := range l.roots {
if strings.HasPrefix(r, path) {
if r == path || strings.HasPrefix(r, terminated) {
return fmt.Errorf(
"cycle detected: new root '%s' contains previous root '%s'",
path, r)