-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Finder] Ignore paths from .gitignore #26714
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
Comments
That's a great idea. |
Do you want to do it @hkdobrev ? |
I'll take a stab at it. |
👋 @naderman @Seldaek I like how this turned out https://github.com/composer/xdebug-handler recently with everything starting from composer/composer#6802 and phpstan/phpstan#605. I'm keen to help on extracting that code out of Composer. A small bit of refactoring would be needed to be usable with an existing finder or to incorporate it into Please let me know if this is something you'd accept help with! Thanks! Approaches: 1️⃣ Extract Composer filters and finder-related code to a |
@hkdobrev The main problem is we can't upgrade to latest Symfony releases, so this is not really that interesting to me, but if you like to duplicate the code in symfony I'd say why not, one day we can use it and drop it from composer.. I'd say option 3 is the best. |
@Seldaek Thanks for the input! I'll try it out. |
There are also some problems with the current implementation composer/composer#5681 And there's an argument to be made that composer should only really care about gitattributes export options and not the ignore file at all, since that's for adding files and not exporting them. |
I have good understanding of the structure in Composer, the latest Finder code and their differences. I've started implementing it with separate filters where people could choose which files to use. When I have something presentable I'll open a PR to request comments on the external API. @naderman Thank you for your input, I'll take these into consideration! |
@hkdobrev are you still working on this? we would like something like this for PHP-CS-Fixer as well :) |
Any updates on this @hkdobrev? |
Hi all, I'm currently working on https://packagist.org/packages/inmarelibero/gitignore-checker can I try to propose an implementation of this issue? |
Hi @inmarelibero |
@amaabdou ah great I decided to implement a stand alone library (also due to the comment of @SpacePossum #26714 (comment)) in order to be reusable everywhere and not too tied with Symfony hint: unfortunately rules cannot be synthetized only with regex, as we could split the work btw: you could work on the PR and I could work on the library? what do you think of it? and if possible of course helping each other ;) I would hear what some mantainer would say about this, as developing things without anyone knowing is a bad practice |
maybe @Simperfit ? |
Sorry @inmarelibero for not replying quickly to you, I was spending my holiday :D Honestly I was looking forward to using regex, it is a little complicated and annoying I know and I was pulling my hair while doing it but seems more convenient for this case but I could be wrong Anyway I submitted the PR with as many cases I could for now, lets see how the review will go, if it went okay then cool, if not we can use the library you created |
This PR was squashed before being merged into the 4.3-dev branch (closes #30448). Discussion ---------- [Finder] Ignore paths from .gitignore #26714 | Q | A | ------------- | --- | Branch? | master for features | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #26714 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> <!-- Write a short README entry for your feature/bugfix here (replace this comment block.) This will help people understand your PR and can be used as a start of the Doc PR. Additionally: - Bug fixes must be submitted against the lowest branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too). - Features and deprecations must be submitted against the master branch. --> Implementation of feature request #26714 Finder::ignoreVCS() is great at ignoring file patterns for the files created by popular VCS systems. However, it would be great to be able to instruct Finder to actually exclude the paths excluded by .gitignore. So if we have .gitignore: vendor/ cache/ Finder::create() ->files() ->ignoreVCS(true) // <--- Ignores `.git` ->ignoreVCSIgnored(true); // <--- Ignores vendor/ and cache/ Commits ------- 9491393 [Finder] Ignore paths from .gitignore #26714
Finder::ignoreVCS()
is great at ignoring file patterns for the files created by popular VCS systems.However, it would be great to be able to instruct
Finder
to actually exclude the paths excluded by.gitignore
.So if we have
.gitignore
:I think this would simplify a lot of Finder configurations which currently manually exclude the git-ignored paths or manually include everything else.
The text was updated successfully, but these errors were encountered: