Skip to content

fix: used finder->exclude instead of notPath for excludedDirs #474

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

Conversation

seizan8
Copy link
Contributor

@seizan8 seizan8 commented Apr 1, 2022

Closes #284 excluded_dirs in config matches filenames too

tested it with my project (exclude_dir "data"). My file "base_data" is now correctly extracted, while translations inside my "data" folder are ignored as expected.

Only possible issue I see is some users expecting "exclude_dirs" to also exclude filenames, which would be a bit weird as it's been marked as bug since 3 years.
Anyway, that could be easily fixed by simply adding the values of "excluded_dirs" to "excluded_names".

Copy link
Member

@bocharsky-bw bocharsky-bw left a comment

Choose a reason for hiding this comment

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

I see PHP CS Fixer failed. Though it's unrelated to this PR, could you fix it, please? The change sounds good anyway

@@ -143,7 +143,7 @@ private function getConfiguredFinder(Configuration $config): Finder
$finder->in($config->getDirs());

foreach ($config->getExcludedDirs() as $exclude) {
$finder->notPath($exclude);
$finder->exclude($exclude);
Copy link
Member

Choose a reason for hiding this comment

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

Hm interesting... I see notPath() could be used for excluding directories as well: https://github.com/symfony/finder/blob/231313534dded84c7ecaa79d14bc5da4ccb69b7d/Finder.php#L274-L275

I don't understand completely why it does not work 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

notPath does apply to files AND directories, while exclude only excludes directories.
So basically notPath should be used if you want to exclude EVERYTHING with a specific name.
Though, I have to say, I don't find "notPath" to be a very intuitive or self-explanatory name...

@seizan8
Copy link
Contributor Author

seizan8 commented Apr 1, 2022

@bocharsky-bw Yeah, I saw the failed test too and quickly fixed it. This should be fine now?

Copy link
Member

@bocharsky-bw bocharsky-bw left a comment

Choose a reason for hiding this comment

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

Thank you for fixing that old issue!

I think changes are good here

@bocharsky-bw bocharsky-bw merged commit 1c0519e into php-translation:master Apr 4, 2022
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.

excluded_dirs in config matches filenames too
2 participants