Skip to content

Conversation

@akash-manna-sky
Copy link
Contributor

@akash-manna-sky akash-manna-sky commented Nov 12, 2025

JENKINS-66810 Use case insensitive matching on Windows

Testing done

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@akash-manna-sky akash-manna-sky marked this pull request as ready for review November 12, 2025 13:37
@uhafner uhafner added the enhancement Enhancement of existing functionality label Nov 12, 2025
@akash-manna-sky
Copy link
Contributor Author

Hello @uhafner please review the changes.

Comment on lines +80 to +117

/**
* 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();
}
}
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement of existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants