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

The pattern_to_regex method does not seem to work correctly on windows. #63

Closed
hakancelikdev opened this issue Sep 4, 2022 · 4 comments

Comments

@hakancelikdev
Copy link

gitignore file is as follows.

a
b
spam/**
**/api/
**/

After converting each line to regex, I have a method called list_path that scans the python files in the current directory and returns the ones that do not match each pattern found in gitignore, and the following test failed in the Windows environment, do you have Windows support for Pathspec?

@excitoon
Copy link

excitoon commented Sep 4, 2022

@hakancelikdev It does not support **/. gitignorefile shall do the job.

@excitoon
Copy link

excitoon commented Sep 4, 2022

Nope, this exact bug was actually fixed in #62 / #41 .

@hakancelikdev
Copy link
Author

Okey thank you

@cpburnz
Copy link
Owner

cpburnz commented Sep 5, 2022

@hakancelikdev Windows is supported by normalizing the Windows path to a POSIX path, and then matching it against the compiled regular expression patterns. If you're using the PathSpec or GitIgnoreSpec classes, they'll handle the normalization for you. Otherwise, you'll need to normalize them with the pathspec.util.normalize_file() function before matching them with the patterns.

For the test that's failing, I'm not sure how utils.list_paths() or utils.get_exclude_list_from_gitignore() use pathspec as those appear to be from unimport.

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

No branches or pull requests

3 participants