Skip to content

Commit

Permalink
[WIP] Fix for #334 (directories like 'dir.yaml' + recursive search)
Browse files Browse the repository at this point in the history
Partially reverts a221898 to fix #334

Linked to cpburnz/python-pathspec#41.
  • Loading branch information
adrienverge committed Oct 10, 2020
1 parent 8eebab6 commit 415b1c7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -5,3 +5,5 @@ __pycache__
/yamllint.egg-info
/build
/.eggs
*.yaml
!*.yaml/
3 changes: 3 additions & 0 deletions yamllint/conf/default.yaml
Expand Up @@ -2,8 +2,11 @@

yaml-files:
- '*.yaml'
- '!*.yaml/'
- '*.yml'
- '!*.yml/'
- '.yamllint'
- '!.yamllint/'

rules:
braces: enable
Expand Down
12 changes: 9 additions & 3 deletions yamllint/config.py
Expand Up @@ -32,8 +32,14 @@ def __init__(self, content=None, file=None):

self.ignore = None

self.yaml_files = pathspec.PathSpec.from_lines(
'gitwildmatch', ['*.yaml', '*.yml', '.yamllint'])
self.yaml_files = pathspec.PathSpec.from_lines('gitwildmatch', [
'*.yaml',
'!*.yaml/',
'*.yml',
'!*.yml/',
'.yamllint',
'!.yamllint/',
])

self.locale = None

Expand All @@ -48,7 +54,7 @@ def is_file_ignored(self, filepath):
return self.ignore and self.ignore.match_file(filepath)

def is_yaml_file(self, filepath):
return self.yaml_files.match_file(os.path.basename(filepath))
return self.yaml_files.match_file(filepath)

def enabled_rules(self, filepath):
return [yamllint.rules.get(id) for id, val in self.rules.items()
Expand Down

0 comments on commit 415b1c7

Please sign in to comment.