Outside of `.pulumiignore` we support a few "default" excludes that try to push folks towards a pit of succes. Previously, there was no way to opt out of these, which would be bad if our huristics caused something youto really care about to be elided. With this change, we add an optional setting in Pulumi.yaml that allows you to opt out of this behavior. As part of the work, I changed .git to be one of these "default" excludes instead of it only happening if you had a .pulumiignore file in a directory
30 lines
778 B
Go
30 lines
778 B
Go
// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
|
|
|
|
package archive
|
|
|
|
import (
|
|
"path"
|
|
"strings"
|
|
|
|
ignore "github.com/sabhiram/go-gitignore"
|
|
)
|
|
|
|
// newPulumiIgnorerIgnorer creates an ignorer based on the contents of a .pulumiignore file, which
|
|
// has the same semantics as a .gitignore file
|
|
func newPulumiIgnorerIgnorer(pathToPulumiIgnore string) (ignorer, error) {
|
|
gitIgnorer, err := ignore.CompileIgnoreFile(pathToPulumiIgnore)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &pulumiIgnoreIgnorer{root: path.Dir(pathToPulumiIgnore), ignorer: gitIgnorer}, nil
|
|
}
|
|
|
|
type pulumiIgnoreIgnorer struct {
|
|
root string
|
|
ignorer *ignore.GitIgnore
|
|
}
|
|
|
|
func (g *pulumiIgnoreIgnorer) IsIgnored(f string) bool {
|
|
return g.ignorer.MatchesPath(strings.TrimPrefix(f, g.root))
|
|
}
|