github.com/ianlewis/go-gitignore@v0.1.1-0.20231110021210-4a0f15cbd56f/match.go (about) 1 // Copyright 2016 Denormal Limited 2 // Copyright 2023 Google LLC 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 package gitignore 17 18 // Match represents the interface of successful matches against a .gitignore 19 // pattern set. A Match can be queried to determine whether the matched path 20 // should be ignored or included (i.e. was the path matched by a negated 21 // pattern), and to extract the position of the pattern within the .gitignore, 22 // and a string representation of the pattern. 23 type Match interface { 24 // Ignore returns true if the match pattern describes files or paths that 25 // should be ignored. 26 Ignore() bool 27 28 // Include returns true if the match pattern describes files or paths that 29 // should be included. 30 Include() bool 31 32 // String returns a string representation of the matched pattern. 33 String() string 34 35 // Position returns the position in the .gitignore file at which the 36 // matching pattern was defined. 37 Position() Position 38 }