Skip to content

Commit

Permalink
Merge pull request #279 from jglick/BindingStepTest.grep
Browse files Browse the repository at this point in the history
Ignore temporary files in `BindingStepTest.grep`
  • Loading branch information
jglick authored Oct 24, 2023
2 parents e6839fa + 0e675c0 commit 737c34d
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
import hudson.slaves.WorkspaceList;
import hudson.util.Secret;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.NoSuchFileException;
import java.util.Collections;
import java.util.Set;
import java.util.TreeSet;
Expand Down Expand Up @@ -468,8 +470,14 @@ private static void grep(File dir, String text, String prefix, Set<String> match
String qualifiedName = prefix + kid.getName();
if (kid.isDirectory()) {
grep(kid, text, qualifiedName + "/", matches);
} else if (kid.isFile() && FileUtils.readFileToString(kid, StandardCharsets.UTF_8).contains(text)) {
matches.add(qualifiedName);
} else {
try {
if (FileUtils.readFileToString(kid, StandardCharsets.UTF_8).contains(text)) {
matches.add(qualifiedName);
}
} catch (FileNotFoundException | NoSuchFileException x) {
// ignore, e.g. tmp file
}
}
}
}
Expand Down

0 comments on commit 737c34d

Please sign in to comment.