Skip to content
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

feat: add ignore option #131

Merged
merged 4 commits into from
Mar 16, 2023
Merged

feat: add ignore option #131

merged 4 commits into from
Mar 16, 2023

Conversation

VincentHardouin
Copy link
Contributor

@VincentHardouin VincentHardouin commented Mar 5, 2023

Allow to ignore folders and files

This required the installation of pathspec, to have the format like the .gitignore

Closes #48 and #80

"""Check if folder is wanted."""
if ignore:
if PathSpec.from_lines("gitwildmatch", ignore).match_file(f"{folder_path}/foo.bar"):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f"{folder_path}/foo.bar" shouldn't this be folder_path?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary 😕. If you remove /foo.bar the tests will not pass
If you have another suggestion, I can try it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like cpburnz/python-pathspec#65 is causing the tests to fail. Seems like pathspec isn't the right fit for our needs. 😕

It might be easier to use something like https://pymotw.com/3/glob/ or our own implementation to check if entries in ignore list matches the path and then return False to ignore it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glob is useful to find filenames, but do not seems helpful for testing path

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like glob internally uses fnmatch. fnmatch seems to be a good fit for this feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just tried fnmatch it's the same problem

@mandarons mandarons merged commit 6eab828 into mandarons:main Mar 16, 2023
@mandarons mandarons linked an issue Mar 16, 2023 that may be closed by this pull request
@VincentHardouin VincentHardouin deleted the feat-add-ignore branch March 16, 2023 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Exclude Files and Folders [FEATURE] Ignore Files
2 participants