Skip to content

Commit

Permalink
Test for no-op libraryPath
Browse files Browse the repository at this point in the history
  • Loading branch information
sboardwell committed Sep 17, 2024
1 parent b748000 commit 506c1df
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package org.jenkinsci.plugins.workflow.libs;

import java.nio.file.Paths;
import java.util.Collections;
import java.util.Set;
import java.util.TreeSet;
Expand Down Expand Up @@ -70,16 +71,25 @@ public final class LibraryRecord {
this.changelog = changelog;
this.cachingConfiguration = cachingConfiguration;
logString = this.name + "@" + this.version;
if (StringUtils.isNotBlank(libraryPath) && !libraryPath.equals(".")) {
if (onTheRoadToNowhere(libraryPath)) {
this.libraryPath = "";
this.directoryName = directoryNameFor(name, version, String.valueOf(trusted), source);
} else {
this.libraryPath = libraryPath;
this.directoryName = directoryNameFor(name, version, String.valueOf(trusted), source, libraryPath);
logString += " from libraryPath: " + libraryPath;
} else {
this.libraryPath = "";
this.directoryName = directoryNameFor(name, version, String.valueOf(trusted), source);
}
}

private boolean onTheRoadToNowhere(String libraryPath) {
if (StringUtils.isBlank(libraryPath)) {
return true;
}
String currentDir = Paths.get("").toAbsolutePath().normalize().toString();
String libraryDir = Paths.get(libraryPath).toAbsolutePath().normalize().toString();
return currentDir.equals(libraryDir);
}

@Exported
public String getName() {
return name;
Expand Down

0 comments on commit 506c1df

Please sign in to comment.