github.com/keleustes/helm@v3.0.0-beta.3+incompatible/internal/ignore/doc.go (about)

     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  /*Package ignore provides tools for writing ignore files (a la .gitignore).
    18  
    19  This provides both an ignore parser and a file-aware processor.
    20  
    21  The format of ignore files closely follows, but does not exactly match, the
    22  format for .gitignore files (https://git-scm.com/docs/gitignore).
    23  
    24  The formatting rules are as follows:
    25  
    26  	- Parsing is line-by-line
    27  	- Empty lines are ignored
    28  	- Lines the begin with # (comments) will be ignored
    29  	- Leading and trailing spaces are always ignored
    30  	- Inline comments are NOT supported ('foo* # Any foo' does not contain a comment)
    31  	- There is no support for multi-line patterns
    32  	- Shell glob patterns are supported. See Go's "path/filepath".Match
    33  	- If a pattern begins with a leading !, the match will be negated.
    34  	- If a pattern begins with a leading /, only paths relatively rooted will match.
    35  	- If the pattern ends with a trailing /, only directories will match
    36  	- If a pattern contains no slashes, file basenames are tested (not paths)
    37  	- The pattern sequence "**", while legal in a glob, will cause an error here
    38  	  (to indicate incompatibility with .gitignore).
    39  
    40  Example:
    41  
    42  	# Match any file named foo.txt
    43  	foo.txt
    44  
    45  	# Match any text file
    46  	*.txt
    47  
    48  	# Match only directories named mydir
    49  	mydir/
    50  
    51  	# Match only text files in the top-level directory
    52  	/*.txt
    53  
    54  	# Match only the file foo.txt in the top-level directory
    55  	/foo.txt
    56  
    57  	# Match any file named ab.txt, ac.txt, or ad.txt
    58  	a[b-d].txt
    59  
    60  Notable differences from .gitignore:
    61  	- The '**' syntax is not supported.
    62  	- The globbing library is Go's 'filepath.Match', not fnmatch(3)
    63  	- Trailing spaces are always ignored (there is no supported escape sequence)
    64  	- The evaluation of escape sequences has not been tested for compatibility
    65  	- There is no support for '\!' as a special leading sequence.
    66  */
    67  package ignore // import "helm.sh/helm/internal/ignore"