Copilot commented on code in PR #384:
URL: 
https://github.com/apache/maven-shared-utils/pull/384#discussion_r3644891641


##########
src/test/java/org/apache/maven/shared/utils/PathToolTest.java:
##########
@@ -102,6 +102,15 @@ public void testGetRelativePath2Parm() {
         assertEquals("", 
PathTool.getRelativePath("/usr/local/java/bin/java.sh", "/usr/local/"));
     }
 
+    @Test
+    public void testGetRelativeFilePathWithDifferentWindowsDrives() {
+        // Tests that the regex fix at line 146 correctly strips a leading 
backslash
+        // before a Windows drive letter. The old regex "^\\[a-zA-Z]:" matched 
the
+        // literal string "[a-zA-Z]:" instead of a backslash + drive letter.
+        // Different drives with leading backslash should return null.

Review Comment:
   The test comment is now outdated and brittle: it refers to a “regex fix” and 
a specific line number. The implementation was changed to a character-level 
check, and line numbers will drift over time, making this comment misleading.



##########
src/main/java/org/apache/maven/shared/utils/PathTool.java:
##########
@@ -143,10 +143,16 @@ public static String getRelativeFilePath(final String 
oldPath, final String newP
         String toPath = new File(newPath).getPath();
 
         // strip any leading slashes if its a windows path
-        if (toPath.matches("^\\[a-zA-Z]:")) {
+        if (toPath.length() > 2

Review Comment:
   This comment says “strip any leading slashes” and uses “its”/“windows”, but 
the code now specifically strips a leading backslash before a Windows drive 
letter. Updating the comment avoids confusion about what input shapes are being 
normalized.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to