Skip to content

Commit

Permalink
Using new VirtualFile.list(String, String, boolean) overload.
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick committed Feb 21, 2018
1 parent 836a784 commit 45720aa
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 29 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -24,8 +24,8 @@
</licenses>

<properties>
<jenkins-core.version>2.109-20180221.170307-1</jenkins-core.version> <!-- TODO https://github.com/jenkinsci/jenkins/pull/3302 -->
<jenkins-war.version>2.109-20180221.170329-1</jenkins-war.version>
<jenkins-core.version>2.109-20180221.200457-2</jenkins-core.version> <!-- TODO https://github.com/jenkinsci/jenkins/pull/3302 -->
<jenkins-war.version>2.109-20180221.200518-2</jenkins-war.version>
<java.level>8</java.level>
</properties>

Expand Down
27 changes: 2 additions & 25 deletions src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
Expand Up @@ -59,7 +59,7 @@
import java.security.DigestOutputStream;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
Expand Down Expand Up @@ -90,8 +90,6 @@
import org.apache.commons.io.IOUtils;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.types.selectors.SelectorUtils;
import org.apache.tools.ant.types.selectors.TokenizedPath;
import org.apache.tools.ant.types.selectors.TokenizedPattern;

/**
* Build step to copy artifacts from another project.
Expand Down Expand Up @@ -544,7 +542,7 @@ private boolean perform(Run src, Run<?,?> dst, String expandedFilter, @CheckForN
}
try {
targetDir.mkdirs(); // Create target if needed
List<String> list = scan(srcDir, expandedFilter, expandedExcludes);
Collection<String> list = srcDir.list(expandedFilter.replace('\\', '/'), expandedExcludes != null ? expandedExcludes.replace('\\', '/') : null, false);
for (String file : list) {
copyOne(src, dst, fingerprints, srcDir.child(file), new FilePath(targetDir, isFlatten() ? file.replaceFirst(".+/", "") : file), md5);
}
Expand All @@ -569,27 +567,6 @@ private boolean perform(Run src, Run<?,?> dst, String expandedFilter, @CheckForN
}
}

private static List<String> scan(VirtualFile root, String expandedFilter, @CheckForNull String expandedExcludes) throws IOException {
List<String> r = new ArrayList<>();
// TODO need VirtualFile.list(String, String, boolean) like FilePath offers
List<TokenizedPattern> patts = new ArrayList<>();
if (expandedExcludes != null) {
for (String patt : expandedExcludes.split(",")) {
patts.add(new TokenizedPattern(normalizePattern(patt)));
}
}
FILE: for (String child : root.list(expandedFilter)) {
child = child.replace('\\', '/'); // TODO list(String) ought to specify `/` as the separator
for (TokenizedPattern patt : patts) {
if (patt.matchPath(new TokenizedPath(child), true)) {
continue FILE;
}
}
r.add(child);
}
return r;
}

/** Similar to a method in {@link DirectoryScanner}. */
private static String normalizePattern(String p) {
String pattern = p.replace('\\', '/'); // we only deal with forward slashes here
Expand Down
Expand Up @@ -543,7 +543,6 @@ public void testCopyFromWorkspace() throws Exception {
assertFile(false, "c.log", b);
}

@Ignore("TODO not yet (re-)implemented")
@Issue("JENKINS-14900")
@Test
public void testCopyFromWorkspaceWithDefaultExcludes() throws Exception {
Expand Down Expand Up @@ -574,7 +573,6 @@ public void testExcludes() throws Exception {
assertFile(false, "foo.txt", b);
}

@Ignore("TODO not yet (re-)implemented")
@Issue("JENKINS-14900")
@Test
public void testCopyFromWorkspaceWithDefaultExcludesWithFlatten() throws Exception {
Expand Down

0 comments on commit 45720aa

Please sign in to comment.