-
Notifications
You must be signed in to change notification settings - Fork 980
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
Tools files rm: Exclude pattern to avoid removing everything #16350
Conversation
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
conan/tools/files/files.py
Outdated
""" | ||
Utility functions to remove files matching a ``pattern`` in a ``folder``. | ||
|
||
:param conanfile: The current recipe object. Always use ``self``. | ||
:param pattern: Pattern that the files to be removed have to match (fnmatch). | ||
:param folder: Folder to search/remove the files. | ||
:param recursive: If ``recursive`` is specified it will search in the subfolders. | ||
:param excludes: Pattern to not be removed when matched with the pattern. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In copy()
this is:
:param excludes: (Optional, defaulted to
None
) A tuple/list of fnmatch patterns or even a
single one to be excluded from the copy.
I think it would be good to use the same logic, and use a list/tuple here for exclusions, not just 1 single value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to align with copy()
using a list as argument
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@memsharded Updated to use tuple or list as parameter. In case passing string, it will be converted to tuple. Same behavior as running in |
Signed-off-by: Uilian Ries <uilianries@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
Greetings!
Added the new parameter
excludes
, same used bytools.files.copy
. This new parameter avoids removing the pattern listed that's also listed by removing pattern. For instance:Changelog: Feature: Add excludes parameter to tools.files.rm to void removing pattern.
Docs: conan-io/docs#3743
closes #16343
develop
branch, documenting this one.