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

Fix copy ignore_case on Windows #7704

Merged
merged 2 commits into from Sep 28, 2020

Conversation

uilianries
Copy link
Member

@uilianries uilianries commented Sep 11, 2020

Changelog: Fix: self.copy() follows igore_case correctly on Windows.
Docs: conan-io/docs#1862

This PR fixes self.copy(ignore_case=True/False) on Windows. The actual behavior, on Windows, ignore_case=False doesn't work.

Fixes #6116

UPDATE:

  • ignore_case=True should be the default, because it's very old bug, and a fix right now would break Windows users.
  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.

@@ -153,7 +153,7 @@ def _filter_files(src, pattern, links, excludes, ignore_case, excluded_folders):
filenames = {f.lower(): f for f in filenames}
pattern = pattern.lower()

files_to_copy = fnmatch.filter(filenames, pattern)
files_to_copy = [n for n in filenames if fnmatch.fnmatchcase(n, pattern)]
Copy link
Member

Choose a reason for hiding this comment

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

This is broken, filter is doing internally some os.path.normcase, which changes / => \ path in Windows too

Copy link
Member

Choose a reason for hiding this comment

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

I am seeing this possibly breaking users, because it is by default ignoring case.
Agree it is a bug, but as most users haven't had to specify it, I would say that the bug is in the default. The default should be ignore_case=True, and then alter the behavior if it is explicitly changed to ignore_case=False. Wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good to me, indeed that's the original behavior, and changing it only after 4 years of project, probably will break users. I'll update this PR to use ignore_case=True by default.

Copy link
Member Author

Choose a reason for hiding this comment

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

About filter, thanks for checking it, I'll search a better way.

Copy link
Member Author

Choose a reason for hiding this comment

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

@memsharded I've split both comparisons, now for non-case-sensitive, it will keep the old behavior, as fnmatch.filter changes all file names to lower-case in Windows due normcase. For case-sensitive check, I kept same modification, but normalizing the path with normpath.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
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.

[bug] copy(ignore_case=False) under Windows
2 participants