Skip to content

Commit c7ba7d9

Browse files
nicksndeloof
authored andcommitted
dockerignore: convert ignore patterns to absolute paths [ch9237] (docker#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 tilt-dev/tilt#3740
1 parent 8b39322 commit c7ba7d9

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

pkg/watch/notify_test.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,6 @@ func TestWatchNonexistentDirectory(t *testing.T) {
421421
f := newNotifyFixture(t)
422422
defer f.tearDown()
423423

424-
ignore, _ := dockerignore.NewDockerPatternMatcher(f.paths[0], []string{"./"})
425-
f.setIgnore(ignore)
426-
427424
root := f.JoinPath("root")
428425
err := os.Mkdir(root, 0777)
429426
if err != nil {
@@ -441,12 +438,9 @@ func TestWatchNonexistentDirectory(t *testing.T) {
441438
t.Fatal(err)
442439
}
443440

444-
if runtime.GOOS == "darwin" {
445-
// for directories that were the root of an Add, we don't report creation, cf. watcher_darwin.go
446-
f.assertEvents()
447-
} else {
448-
f.assertEvents(parent)
449-
}
441+
// for directories that were the root of an Add, we don't report creation, cf. watcher_darwin.go
442+
f.assertEvents()
443+
450444
f.events = nil
451445
f.WriteFile(file, "hello")
452446

@@ -457,9 +451,6 @@ func TestWatchNonexistentFileInNonexistentDirectory(t *testing.T) {
457451
f := newNotifyFixture(t)
458452
defer f.tearDown()
459453

460-
ignore, _ := dockerignore.NewDockerPatternMatcher(f.paths[0], []string{"./"})
461-
f.setIgnore(ignore)
462-
463454
root := f.JoinPath("root")
464455
err := os.Mkdir(root, 0777)
465456
if err != nil {

pkg/watch/watcher_naive.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,12 @@ func (d *naiveNotify) shouldNotify(path string) bool {
214214
}
215215

216216
if _, ok := d.notifyList[path]; ok {
217+
// We generally don't care when directories change at the root of an ADD
218+
stat, err := os.Lstat(path)
219+
isDir := err == nil && stat.IsDir()
220+
if isDir {
221+
return false
222+
}
217223
return true
218224
}
219225
// TODO(dmiller): maybe use a prefix tree here?

0 commit comments

Comments
 (0)