-
Notifications
You must be signed in to change notification settings - Fork 290
/
ephemeral.go
39 lines (34 loc) · 1.54 KB
/
ephemeral.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package ignore
import (
"github.com/windmilleng/tilt/internal/dockerignore"
"github.com/windmilleng/tilt/pkg/model"
)
// Filter 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 if those files aren't
// there or aren't in the right places.
//
// https://app.clubhouse.io/windmill/story/691/filter-out-ephemeral-file-changes
var ephemeralPathMatcher = initEphemeralPathMatcher()
func initEphemeralPathMatcher() model.PathMatcher {
golandPatterns := []string{"**/*___jb_old___", "**/*___jb_tmp___", "**/.idea/**"}
emacsPatterns := []string{"**/.#*"}
// if .swp is taken (presumably because multiple vims are running in that dir),
// vim will go with .swo, .swn, etc, and then even .svz, .svy!
// https://github.com/vim/vim/blob/ea781459b9617aa47335061fcc78403495260315/src/memline.c#L5076
// ignoring .sw? seems dangerous, since things like .swf or .swi exist, but ignoring the first few
// seems safe and should catch most cases
vimPatterns := []string{"**/4913", "**/*~", "**/.*.swp", "**/.*.swx", "**/.*.swo", "**/.*.swn"}
allPatterns := []string{}
allPatterns = append(allPatterns, golandPatterns...)
allPatterns = append(allPatterns, emacsPatterns...)
allPatterns = append(allPatterns, vimPatterns...)
matcher, err := dockerignore.NewDockerPatternMatcher("/", allPatterns)
if err != nil {
panic(err)
}
return matcher
}