-
Notifications
You must be signed in to change notification settings - Fork 192
[JENKINS-66810] Use case insensitive matching on Windows #1273
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
base: main
Are you sure you want to change the base?
Conversation
|
Hello @uhafner please review the changes. |
|
|
||
| /** | ||
| * Finds the actual file path with correct capitalization on Windows. | ||
| * On Windows, file systems are case-insensitive but case-preserving, so we need to find the actual file name as it exists on disk. | ||
| * | ||
| * @param relativeFileName | ||
| * the relative file name (possibly with wrong capitalization) | ||
| * @param sourceDirectoryPrefix | ||
| * the source directory prefix | ||
| * | ||
| * @return the actual relative file name with correct capitalization, or empty if not found | ||
| */ | ||
| private Optional<String> findActualFilePath(final String relativeFileName, final String sourceDirectoryPrefix) { | ||
| if (!IS_WINDOWS) { | ||
| return PATH_UTIL.exists(relativeFileName, sourceDirectoryPrefix) | ||
| ? Optional.of(relativeFileName) | ||
| : Optional.empty(); | ||
| } | ||
|
|
||
| try { | ||
| var basePath = Path.of(sourceDirectoryPrefix); | ||
| var targetPath = basePath.resolve(relativeFileName); | ||
|
|
||
| if (!Files.exists(targetPath)) { | ||
| return Optional.empty(); | ||
| } | ||
|
|
||
| var realPath = targetPath.toRealPath(); | ||
|
|
||
| var relativePath = basePath.relativize(realPath); | ||
| String actualRelativeFileName = relativePath.toString().replace('\\', '/'); | ||
|
|
||
| return Optional.of(actualRelativeFileName); | ||
| } | ||
| catch (IOException | InvalidPathException exception) { | ||
| return Optional.empty(); | ||
| } | ||
| } |
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.
Are you running on Windows? When I run your test without the changes in the FileNameResolver, then the tests passes (see #1275). It would make sense to produce a test that actually fails.
I see no value in the new code when the tests still passes without. The original issue was more a review task for me to look through the various code places (here and in the warnings plugin) to detect incompatibilities with Windows.
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.
Yes, I am running on Windows.
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.
Does the test fail on your machine without your change?
JENKINS-66810 Use case insensitive matching on Windows
Testing done
Submitter checklist