akashchamp commented on code in PR #252:
URL: 
https://github.com/apache/maven-artifact-plugin/pull/252#discussion_r4057314023


##########
src/main/java/org/apache/maven/plugins/artifact/buildinfo/CompareMojo.java:
##########
@@ -325,9 +328,8 @@ private String diffoscope(Artifact a, File referenceDir) 
throws MojoExecutionExc
         return "diffoscope " + relative(reference) + " " + relative(actual);
     }
 
-    private String getRepositoryFilename(Artifact a) {
-        String path = 
session.getRepositorySession().getLocalRepositoryManager().getPathForLocalArtifact(a);
-        return path.substring(path.lastIndexOf('/'));
+    static String getRepositoryFilename(String path) {

Review Comment:
   Reverted the restructuring: getRepositoryFilename(Artifact) is private again 
with its original signature, so the diff against master is now just the return 
line (Paths.get(path).getFileName() instead of substring) plus the Paths import.
   



##########
src/test/java/org/apache/maven/plugins/artifact/buildinfo/CompareMojoTest.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugins.artifact.buildinfo;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class CompareMojoTest {
+    @Test
+    void getsRepositoryFilenameWithoutDirectory() {

Review Comment:
   Dropped the unit test and replaced it with an invoker IT, 
compare-flat-local-repository, which goes through artifact:compare end to end: 
a small core extension built by setup-flat-local-repository wraps the default 
local repository manager so getPathForLocalArtifact() returns a bare filename 
on the rebuild. Without the fix the IT fails with the 
StringIndexOutOfBoundsException from #248; with it, verify.groovy checks the 
expected .buildcompare output on both Maven 3 and 4.
   



-- 
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