Browse Source

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
Nick Santos 5 years ago
parent
commit
c7ba7d9de5
2 changed files with 9 additions and 12 deletions
  1. 3 12
      pkg/watch/notify_test.go
  2. 6 0
      pkg/watch/watcher_naive.go

+ 3 - 12
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 {

+ 6 - 0
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?