github.com/grahambrereton-form3/tilt@v0.10.18/internal/ignore/ephemeral.go (about)

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