Skip to content

Commit 32a9528

Browse files
committed
[pathspec >= 1.0.0] Update with GitIgnoreSpec.from_lines
To follow Git's implementation, use GitIgnoreSpec.from_lines(...). The change for using this is Git allows including files from excluded directories which directly contradicts the gitignore docs. See #800 (comment) Fixes #800 Signed-off-by: Wong Hoi Sing Edison <[email protected]>
1 parent 73b9c0b commit 32a9528

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

yamllint/config.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ def __init__(self, content=None, file=None):
3232

3333
self.ignore = None
3434

35-
self.yaml_files = pathspec.PathSpec.from_lines(
36-
'gitwildmatch', ['*.yaml', '*.yml', '.yamllint'])
35+
self.yaml_files = pathspec.GitIgnoreSpec.from_lines(
36+
'gitignore', ['*.yaml', '*.yml', '.yamllint'])
3737

3838
self.locale = None
3939

@@ -112,18 +112,18 @@ def parse(self, raw_content):
112112
raise YamlLintConfigError(
113113
'invalid config: ignore-from-file should contain '
114114
'filename(s), either as a list or string')
115-
self.ignore = pathspec.PathSpec.from_lines(
116-
'gitwildmatch',
115+
self.ignore = pathspec.GitIgnoreSpec.from_lines(
116+
'gitignore',
117117
decoder.lines_in_files(conf['ignore-from-file'])
118118
)
119119
elif 'ignore' in conf:
120120
if isinstance(conf['ignore'], str):
121-
self.ignore = pathspec.PathSpec.from_lines(
122-
'gitwildmatch', conf['ignore'].splitlines())
121+
self.ignore = pathspec.GitIgnoreSpec.from_lines(
122+
'gitignore', conf['ignore'].splitlines())
123123
elif (isinstance(conf['ignore'], list) and
124124
all(isinstance(line, str) for line in conf['ignore'])):
125-
self.ignore = pathspec.PathSpec.from_lines(
126-
'gitwildmatch', conf['ignore'])
125+
self.ignore = pathspec.GitIgnoreSpec.from_lines(
126+
'gitignore', conf['ignore'])
127127
else:
128128
raise YamlLintConfigError(
129129
'invalid config: ignore should contain file patterns')
@@ -134,8 +134,8 @@ def parse(self, raw_content):
134134
raise YamlLintConfigError(
135135
'invalid config: yaml-files '
136136
'should be a list of file patterns')
137-
self.yaml_files = pathspec.PathSpec.from_lines('gitwildmatch',
138-
conf['yaml-files'])
137+
self.yaml_files = pathspec.GitIgnoreSpec.from_lines(
138+
'gitignore', conf['yaml-files'])
139139

140140
if 'locale' in conf:
141141
if not isinstance(conf['locale'], str):
@@ -168,19 +168,19 @@ def validate_rule_conf(rule, conf):
168168
raise YamlLintConfigError(
169169
'invalid config: ignore-from-file should contain '
170170
'valid filename(s), either as a list or string')
171-
conf['ignore'] = pathspec.PathSpec.from_lines(
172-
'gitwildmatch',
171+
conf['ignore'] = pathspec.GitIgnoreSpec.from_lines(
172+
'gitignore',
173173
decoder.lines_in_files(conf['ignore-from-file'])
174174
)
175175
elif ('ignore' in conf and not isinstance(
176176
conf['ignore'], pathspec.pathspec.PathSpec)):
177177
if isinstance(conf['ignore'], str):
178-
conf['ignore'] = pathspec.PathSpec.from_lines(
179-
'gitwildmatch', conf['ignore'].splitlines())
178+
conf['ignore'] = pathspec.GitIgnoreSpec.from_lines(
179+
'gitignore', conf['ignore'].splitlines())
180180
elif (isinstance(conf['ignore'], list) and
181181
all(isinstance(line, str) for line in conf['ignore'])):
182-
conf['ignore'] = pathspec.PathSpec.from_lines(
183-
'gitwildmatch', conf['ignore'])
182+
conf['ignore'] = pathspec.GitIgnoreSpec.from_lines(
183+
'gitignore', conf['ignore'])
184184
else:
185185
raise YamlLintConfigError(
186186
'invalid config: ignore should contain file patterns')

0 commit comments

Comments
 (0)