ephemeral.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package ignore
  2. import (
  3. "github.com/tilt-dev/tilt/internal/dockerignore"
  4. "github.com/tilt-dev/tilt/pkg/model"
  5. )
  6. // Filter out spurious changes that we don't want to rebuild on, like IDE
  7. // temp/lock files.
  8. //
  9. // This isn't an ideal solution. In an ideal world, the user would put
  10. // everything to ignore in their tiltignore/dockerignore files. This is a
  11. // stop-gap so they don't have a terrible experience if those files aren't
  12. // there or aren't in the right places.
  13. //
  14. // https://app.clubhouse.io/windmill/story/691/filter-out-ephemeral-file-changes
  15. var ephemeralPathMatcher = initEphemeralPathMatcher()
  16. func initEphemeralPathMatcher() model.PathMatcher {
  17. golandPatterns := []string{"**/*___jb_old___", "**/*___jb_tmp___", "**/.idea/**"}
  18. emacsPatterns := []string{"**/.#*"}
  19. // if .swp is taken (presumably because multiple vims are running in that dir),
  20. // vim will go with .swo, .swn, etc, and then even .svz, .svy!
  21. // https://github.com/vim/vim/blob/ea781459b9617aa47335061fcc78403495260315/src/memline.c#L5076
  22. // ignoring .sw? seems dangerous, since things like .swf or .swi exist, but ignoring the first few
  23. // seems safe and should catch most cases
  24. vimPatterns := []string{"**/4913", "**/*~", "**/.*.swp", "**/.*.swx", "**/.*.swo", "**/.*.swn"}
  25. // kate (the default text editor for KDE) uses a file similar to Vim's .swp
  26. // files, but it doesn't have the "incrememnting" character problem mentioned
  27. // above
  28. katePatterns := []string{"**/.*.kate-swp"}
  29. allPatterns := []string{}
  30. allPatterns = append(allPatterns, golandPatterns...)
  31. allPatterns = append(allPatterns, emacsPatterns...)
  32. allPatterns = append(allPatterns, vimPatterns...)
  33. allPatterns = append(allPatterns, katePatterns...)
  34. matcher, err := dockerignore.NewDockerPatternMatcher("/", allPatterns)
  35. if err != nil {
  36. panic(err)
  37. }
  38. return matcher
  39. }