From c7ba7d9de52edfc70bab85930e2e44583d887d4d Mon Sep 17 00:00:00 2001 From: Nick Santos Date: Wed, 2 Sep 2020 15:55:37 -0400 Subject: [PATCH] dockerignore: convert ignore patterns to absolute paths [ch9237] (#3743) In most places in Tilt, we try to use absolute paths everywhere. So this makes things more consistent with the rest of Tilt, and lets us be a bit more flexible in how we handle subdirs and parent dirs in ignores. Fixes https://github.com/tilt-dev/tilt/issues/3740 --- pkg/watch/notify_test.go | 15 +++------------ pkg/watch/watcher_naive.go | 6 ++++++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/watch/notify_test.go b/pkg/watch/notify_test.go index 97ae8201..835ab5c0 100644 --- a/pkg/watch/notify_test.go +++ b/pkg/watch/notify_test.go @@ -421,9 +421,6 @@ func TestWatchNonexistentDirectory(t *testing.T) { f := newNotifyFixture(t) defer f.tearDown() - ignore, _ := dockerignore.NewDockerPatternMatcher(f.paths[0], []string{"./"}) - f.setIgnore(ignore) - root := f.JoinPath("root") err := os.Mkdir(root, 0777) if err != nil { @@ -441,12 +438,9 @@ func TestWatchNonexistentDirectory(t *testing.T) { t.Fatal(err) } - if runtime.GOOS == "darwin" { - // for directories that were the root of an Add, we don't report creation, cf. watcher_darwin.go - f.assertEvents() - } else { - f.assertEvents(parent) - } + // for directories that were the root of an Add, we don't report creation, cf. watcher_darwin.go + f.assertEvents() + f.events = nil f.WriteFile(file, "hello") @@ -457,9 +451,6 @@ func TestWatchNonexistentFileInNonexistentDirectory(t *testing.T) { f := newNotifyFixture(t) defer f.tearDown() - ignore, _ := dockerignore.NewDockerPatternMatcher(f.paths[0], []string{"./"}) - f.setIgnore(ignore) - root := f.JoinPath("root") err := os.Mkdir(root, 0777) if err != nil { diff --git a/pkg/watch/watcher_naive.go b/pkg/watch/watcher_naive.go index 2874fd45..637ac88c 100644 --- a/pkg/watch/watcher_naive.go +++ b/pkg/watch/watcher_naive.go @@ -214,6 +214,12 @@ func (d *naiveNotify) shouldNotify(path string) bool { } if _, ok := d.notifyList[path]; ok { + // We generally don't care when directories change at the root of an ADD + stat, err := os.Lstat(path) + isDir := err == nil && stat.IsDir() + if isDir { + return false + } return true } // TODO(dmiller): maybe use a prefix tree here?