Skip to content

Commit

Permalink
Fix MetaMainHasInfoRule when running from meta dir (#1493)
Browse files Browse the repository at this point in the history
When ansible-lint is run directly from the meta directory for meta/main.yml, file.path is simply 'main.yml' and fails the `str(file.path).endswith('/main.yml')` test.
We can instead compare the name attribute of the Path object to 'main.yml'.
  • Loading branch information
Udyrfrykte authored Mar 25, 2021
1 parent a956ebc commit 8a5eddf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/MetaMainHasInfoRule.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def matchplay(self, file: Lintable, data: "odict[str, Any]") -> List[MatchError]

# since Ansible 2.10 we can add a meta/requirements.yml but
# we only want to match on meta/main.yml
if not str(file.path).endswith('/main.yml'):
if file.path.name != 'main.yml':
return []

galaxy_info = data.get('galaxy_info', False)
Expand Down

0 comments on commit 8a5eddf

Please sign in to comment.