-
Notifications
You must be signed in to change notification settings - Fork 656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Directories with trailing slash in .gitignore will not be exluded in version 6.17 #3524
Comments
easy fix would be for example to change the lines ansible-lint/src/ansiblelint/file_utils.py Lines 563 to 565 in 98063af
to pathspecs.append(
pathspec.GitIgnoreSpec.from_lines(line.strip("/") for line in f.read().splitlines()),
) |
@hille721 Thanks for the very well written report! Would you mind making PR to address it? |
|
ok found a similar issue, which the guys from black project had: cpburnz/python-pathspec#65 |
That is brilliant, I wanted to suggest you to look at black as they are heavy users of pathspec. |
Summary
directories with trailing slashes in
.gitignore
won't be exluded in ansible-lint 6.17.0.I guess this is related to the reimplementation of the file exclusion logic (#3507).
This statement
ansible-lint/src/ansiblelint/file_utils.py
Line 541 in 98063af
false
for a comparison of Path(foo
) withfoo/
in the pathspec object. It will even returnfalse
forPath('foo/')
as pathlib will strip trailing slashes (see python/cpython#65238)Issue Type
OS / ENVIRONMENT
STEPS TO REPRODUCE
This will result in following error:
As you can see, it won't be excluded.
Desired Behavior
It should work the same as if the directory is specified without trailing slash:
The text was updated successfully, but these errors were encountered: