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

Add an option to skip paths (e.g. node_modules) #264

Closed
drewbrew opened this issue Nov 12, 2020 · 8 comments
Closed

Add an option to skip paths (e.g. node_modules) #264

drewbrew opened this issue Nov 12, 2020 · 8 comments
Labels
enhancement New feature or request

Comments

@drewbrew
Copy link

Is your feature request related to a problem? Please describe.
I use django-tailwind for CSS in a project. One of the JS libraries it imports has some Python 2 code that it puts inside my theme/static_src/node_modules/ directory, which is already in my .gitignore. Because my project is using Python 3.8, the code modder throws syntax errors for those 23 files (which is technically correct).

Describe the solution you'd like
I'd like the ability to exclude paths (via a command-line switch or other means) or have the option to have django-codemod skip files ignored by git.

Additional context
N/A, but this tool is excellent!

@drewbrew drewbrew added the enhancement New feature or request label Nov 12, 2020
@browniebroke
Copy link
Owner

Yes, sounds like a reasonable to add an exclude option. I think this option should be repeatable (to allow excluding multiple paths).

Pull request welcome.

@browniebroke
Copy link
Owner

Implementation note: we currently use the gather_files function from libCST to get the list of files to codemod.

We might want to copy that function in django-codemod and change it to support exclusion. In terms of how it's exposed to the user, we could take the --exclude option from black as inspiration, with a list of sensible defaults (the same ones?).

@browniebroke
Copy link
Owner

Digging through black source code, I realised that it parses .gitignore file and ignores anything matching it. It seems like it would solve your problem as well as similar ones with virtualenv (#278)...

@browniebroke
Copy link
Owner

browniebroke commented Jan 2, 2021

I just published version 1.1.0 which should now honor the content of .gitignore. Does it solve your problem?

@drewbrew
Copy link
Author

drewbrew commented Jan 7, 2021

@browniebroke This should be perfect. Thank you!

I'll download and try it out just to make sure.

@drewbrew
Copy link
Author

drewbrew commented Jan 7, 2021

Confirmed, it works wonderfully.

One thing to note: it only seems to parse the top-level .gitignore; if a subdirectory has its own version, git respects that but this tool does not.

@browniebroke
Copy link
Owner

Yes that seems about right. It just parsing one from the repo root. Do you have many gitignore? Wondering if we could just document it or if we should try to handle it...

@drewbrew
Copy link
Author

drewbrew commented Jan 7, 2021

I think document it and be done. It's a rare pattern that shouldn't really exist outside of using submodules in my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants