Fix IgnoreRule#isMatch returning wrong result due to missing reset
The matcher has to be reset before using it, as was already done in the other cases. Bug: 423039 Change-Id: I87abaa7ad7f0aac8651db6e88d41427cacb4d776 Also-by: Ondrej Vrabec <ovrabec@netbeans.org> Signed-off-by: Robin Stocker <robin@nibor.org>
This commit is contained in:
parent
7dc8a4f089
commit
f4dae204a6
|
@ -340,6 +340,18 @@ public void testGetters() {
|
|||
assertEquals(r.getPattern(), "/patter?");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResetState() {
|
||||
String pattern = "/build/*";
|
||||
String target = "/build";
|
||||
// Don't use the assert methods of this class, as we want to test
|
||||
// whether the state in IgnoreRule is reset properly
|
||||
IgnoreRule r = new IgnoreRule(pattern);
|
||||
// Result should be the same for the same inputs
|
||||
assertFalse(r.isMatch(target, true));
|
||||
assertFalse(r.isMatch(target, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for a match. If target ends with "/", match will assume that the
|
||||
* target is meant to be a directory.
|
||||
|
|
|
@ -198,6 +198,7 @@ public boolean isMatch(String target, boolean isDirectory) {
|
|||
}
|
||||
|
||||
} else {
|
||||
matcher.reset();
|
||||
matcher.append(target);
|
||||
if (matcher.isMatch())
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue