-
Notifications
You must be signed in to change notification settings - Fork 77
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
Automatically exclude .gitignore
content
#909
Comments
hi @aheritier ; thanks for the suggestion! I would have sworn we had something like that already, but I can't find it right now so perhaps I'm mistaken, or confused with the Moderne CLI. There's perhaps two parts to this: one is whether we want to parse files in .gitignore, and another if we want to modify files in .gitignore. While I agree with you that it's often the case that we could skip any git ignored files, there might also be cases where folks for instance have a code generator that creates files in a git ignored path. Those files might then have to be parsed to get complete type information, or even modified if they want recipes applied before they are packaged up. As such it's hard to say if we can blanket skip any git ignored files from both parsing and modifications. For some common cases like node_modules we already have those ignored by default. Are there any other common patterns that you think should be excluded perhaps? Welcome to help think this through; either way it sounds like this should be optional at least, as to not rule out the above cases. |
Hi tim, Good point. We should have different rules for parsing vs modifying (at least we could configure them differently). In fact I realized this "issue" when I saw warnings in "Parsing source files" step about large files which are all in folders I excluded in
I don't feel it has a performance impact thus maybe it's ok to keep it like this. |
@timtebeek, here's the link: To the point though, there are often a lot of other directories that may be ignored beyond the default set. On the flip side, as Tim knows already, sometimes files that are Git ignored have to be parsed to produce enough information for type attribution. It's definitely a balance. |
Thanks for the hint @shanman190 ! Indeed the OmniParser has two different ways of walking a file tree, depending on whether it's a git repositry or not; if it's a Git repository then we already call out to jgit to see if the entry is ignored. From the looks of it (and knowing) @aheritier he'll be using the rewrite Maven plugin, which does not use the OmniParser, and lacks a similar mechanism to skip git ignored files (for now). For the .java/.kt sources that mechanism would need to be added here, whereas for other resources we can add that here, or swap in the OmniParser there for consistency. With that I think this issue uniquely affects our Maven plugin, so I'll move the issue there. Thanks all! |
It makes sense to me @timtebeek and thanks for your feedbacks @shanman190 |
Yes I think we can do better; for comparison, the Gradle project parser does use the OmniParser, and skips over already parsed files, as well as anything that is Git ignored. From the looks of it, most of what's in the Maven plugin's ResourceParser can move to use the OmniParser to gain that git ignore most easily. Something to look into, if I find the time. |
Thanks Tim. It's not blocker/urgent. I might try to look at it but it won't be before 6 months. |
.gitignore
content
What problem are you trying to solve?
Our project use Git as SCM (classical) and has a
.gitignore
file to exclude some files and folders which shouldn't be store in the SCM (often large folders like node_modules etc). OpenRewrite proposes a manual option to exclude some folders from the update. By default, or at least optionally it should allow to follow the .gitignore content because it is 99.99999% sure that you never want to update them (whatever are the update rules in the recipes).Describe the solution you'd like
Either by default and in any case with an option to turn on or off the feature to respect the .gitignore content
Have you considered any alternatives or workarounds?
For now I manually add exclusion entries to avoid to scan the whole project.
The text was updated successfully, but these errors were encountered: