Skip to content

Commit 7daccc6

Browse files
committed
Revert commit 53eddaf
BUG=476444550 GWSQ_IGNORE: linjordan@google.com PiperOrigin-RevId: 857282869 Change-Id: Id63bfee7daaf8c652a0a1bbfb90987bc050d9585
1 parent dac5f0f commit 7daccc6

File tree

1 file changed

+5
-32
lines changed

1 file changed

+5
-32
lines changed

java/com/google/copybara/util/SequenceGlob.java

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616

1717
package com.google.copybara.util;
1818

19+
import static com.google.common.collect.ImmutableList.toImmutableList;
20+
1921
import com.google.common.collect.ImmutableList;
20-
import com.google.common.collect.ImmutableSet;
2122
import com.google.copybara.util.GlobAtom.AtomType;
22-
import java.nio.file.FileSystem;
2323
import java.nio.file.Path;
2424
import java.nio.file.PathMatcher;
2525
import net.starlark.java.eval.EvalException;
@@ -38,40 +38,13 @@ String toStringWithParentheses(boolean isRootGlob) {
3838
}
3939

4040
@Override
41-
public PathMatcher relativeTo(Path root) {
42-
ImmutableSet.Builder<Path> paths = ImmutableSet.builder();
43-
for (GlobAtom atom : include) {
44-
paths.add(resolvePath(root, atom.pattern()));
45-
}
46-
final ImmutableSet<Path> matchPaths = paths.build();
41+
public PathMatcher relativeTo(Path path) {
4742
return new ReadablePathMatcher(
48-
new PathMatcher() {
49-
@Override
50-
public boolean matches(Path path) {
51-
return matchPaths.contains(path.normalize());
52-
}
53-
54-
@Override
55-
public String toString() {
56-
return SequenceGlob.this.toString();
57-
}
58-
},
43+
FileUtil.anyPathMatcher(
44+
include.stream().map(g -> g.matcher(path)).collect(toImmutableList())),
5945
this.toString());
6046
}
6147

62-
private Path resolvePath(Path root, String pattern) {
63-
// Logic from GlobAtom.SINGLE_FILE.matcher
64-
FileSystem fs = root.getFileSystem();
65-
String rootStr = root.normalize().toString();
66-
String separator = fs.getSeparator();
67-
68-
if (!rootStr.endsWith(separator)) {
69-
rootStr += separator;
70-
}
71-
72-
return fs.getPath(rootStr + pattern);
73-
}
74-
7548
public static SequenceGlob ofStarlarkList(StarlarkList<?> patterns) throws EvalException {
7649
ImmutableList.Builder<GlobAtom> atoms = ImmutableList.builder();
7750
for (Object pattern : patterns) {

0 commit comments

Comments
 (0)