MCPcopy
hub / github.com/docker/compose / EphemeralPathMatcher

Function EphemeralPathMatcher

pkg/watch/ephemeral.go:29–59  ·  view source on GitHub ↗

EphemeralPathMatcher filters out spurious changes that we don't want to rebuild on, like IDE temp/lock files. This isn't an ideal solution. In an ideal world, the user would put everything to ignore in their tiltignore/dockerignore files. This is a stop-gap so they don't have a terrible experience

()

Source from the content-addressed store, hash-verified

27// NOTE: The underlying `patternmatcher` is NOT always Goroutine-safe, so
28// this is not a singleton; we create an instance for each watcher currently.
29func EphemeralPathMatcher() PathMatcher {
30 golandPatterns := []string{"**/*___jb_old___", "**/*___jb_tmp___", "**/.idea/**"}
31 emacsPatterns := []string{"**/.#*", "**/#*#"}
32 // if .swp is taken (presumably because multiple vims are running in that dir),
33 // vim will go with .swo, .swn, etc, and then even .svz, .svy!
34 // https://github.com/vim/vim/blob/ea781459b9617aa47335061fcc78403495260315/src/memline.c#L5076
35 // ignoring .sw? seems dangerous, since things like .swf or .swi exist, but ignoring the first few
36 // seems safe and should catch most cases
37 vimPatterns := []string{"**/4913", "**/*~", "**/.*.swp", "**/.*.swx", "**/.*.swo", "**/.*.swn"}
38 // kate (the default text editor for KDE) uses a file similar to Vim's .swp
39 // files, but it doesn't have the "incrementing" character problem mentioned
40 // above
41 katePatterns := []string{"**/.*.kate-swp"}
42 // go stdlib creates tmpfiles to determine umask for setting permissions
43 // during file creation; they are then immediately deleted
44 // https://github.com/golang/go/blob/0b5218cf4e3e5c17344ea113af346e8e0836f6c4/src/cmd/go/internal/work/exec.go#L1764
45 goPatterns := []string{"**/*-go-tmp-umask"}
46
47 var allPatterns []string
48 allPatterns = append(allPatterns, golandPatterns...)
49 allPatterns = append(allPatterns, emacsPatterns...)
50 allPatterns = append(allPatterns, vimPatterns...)
51 allPatterns = append(allPatterns, katePatterns...)
52 allPatterns = append(allPatterns, goPatterns...)
53
54 matcher, err := NewDockerPatternMatcher("/", allPatterns)
55 if err != nil {
56 panic(err)
57 }
58 return matcher
59}

Callers 3

TestEphemeralPathMatcherFunction · 0.92
getWatchRulesFunction · 0.92
initialSyncMethod · 0.92

Calls 1

NewDockerPatternMatcherFunction · 0.85

Tested by 1

TestEphemeralPathMatcherFunction · 0.74