1 /* 2 Copyright The Helm Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 /* 18 Package ignore provides tools for writing ignore files (a la .gitignore). 19 20 This provides both an ignore parser and a file-aware processor. 21 22 The format of ignore files closely follows, but does not exactly match, the 23 format for .gitignore files (https://git-scm.com/docs/gitignore). 24 25 The formatting rules are as follows: 26 27 - Parsing is line-by-line 28 - Empty lines are ignored 29 - Lines the begin with # (comments) will be ignored 30 - Leading and trailing spaces are always ignored 31 - Inline comments are NOT supported ('foo* # Any foo' does not contain a comment) 32 - There is no support for multi-line patterns 33 - Shell glob patterns are supported. See Go's "path/filepath".Match 34 - If a pattern begins with a leading !, the match will be negated. 35 - If a pattern begins with a leading /, only paths relatively rooted will match. 36 - If the pattern ends with a trailing /, only directories will match 37 - If a pattern contains no slashes, file basenames are tested (not paths) 38 - The pattern sequence "**", while legal in a glob, will cause an error here 39 (to indicate incompatibility with .gitignore). 40 41 Example: 42 43 # Match any file named foo.txt 44 foo.txt 45 46 # Match any text file 47 *.txt 48 49 # Match only directories named mydir 50 mydir/ 51 52 # Match only text files in the top-level directory 53 /*.txt 54 55 # Match only the file foo.txt in the top-level directory 56 /foo.txt 57 58 # Match any file named ab.txt, ac.txt, or ad.txt 59 a[b-d].txt 60 61 Notable differences from .gitignore: 62 - The '**' syntax is not supported. 63 - The globbing library is Go's 'filepath.Match', not fnmatch(3) 64 - Trailing spaces are always ignored (there is no supported escape sequence) 65 - The evaluation of escape sequences has not been tested for compatibility 66 - There is no support for '\!' as a special leading sequence. 67 */ 68 package ignore // import "helm.sh/helm/v3/pkg/ignore" 69