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
This commit is contained in:
Nick Santos 2020-09-02 15:55:37 -04:00 committed by Nicolas De loof
parent 8b39322365
commit c7ba7d9de5
2 changed files with 9 additions and 12 deletions

View File

@ -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 {

View File

@ -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?