|
|
@@ -91,9 +91,9 @@ public class IgnoreRule { |
|
|
|
endIndex --; |
|
|
|
dirOnly = true; |
|
|
|
} |
|
|
|
boolean hasSlash = pattern.contains("/"); |
|
|
|
|
|
|
|
pattern = pattern.substring(startIndex, endIndex); |
|
|
|
boolean hasSlash = pattern.contains("/"); |
|
|
|
|
|
|
|
if (!hasSlash) |
|
|
|
nameOnly = true; |
|
|
@@ -188,8 +188,11 @@ public class IgnoreRule { |
|
|
|
|
|
|
|
if (nameOnly) { |
|
|
|
//Iterate through each sub-name |
|
|
|
for (String folderName : target.split("/")) { |
|
|
|
if (folderName.equals(pattern)) |
|
|
|
final String[] segments = target.split("/"); |
|
|
|
for (int idx = 0; idx < segments.length; idx++) { |
|
|
|
final String segmentName = segments[idx]; |
|
|
|
if (segmentName.equals(pattern) && |
|
|
|
doesMatchDirectoryExpectations(isDirectory, idx, segments.length)) |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@@ -199,23 +202,29 @@ public class IgnoreRule { |
|
|
|
if (matcher.isMatch()) |
|
|
|
return true; |
|
|
|
|
|
|
|
final String[] segments = target.split("/"); |
|
|
|
if (nameOnly) { |
|
|
|
for (String folderName : target.split("/")) { |
|
|
|
for (int idx = 0; idx < segments.length; idx++) { |
|
|
|
final String segmentName = segments[idx]; |
|
|
|
//Iterate through each sub-directory |
|
|
|
matcher.reset(); |
|
|
|
matcher.append(folderName); |
|
|
|
if (matcher.isMatch()) |
|
|
|
matcher.append(segmentName); |
|
|
|
if (matcher.isMatch() && |
|
|
|
doesMatchDirectoryExpectations(isDirectory, idx, segments.length)) |
|
|
|
return true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
//TODO: This is the slowest operation |
|
|
|
//This matches e.g. "/src/ne?" to "/src/new/file.c" |
|
|
|
matcher.reset(); |
|
|
|
for (String folderName : target.split("/")) { |
|
|
|
if (folderName.length() > 0) |
|
|
|
matcher.append("/" + folderName); |
|
|
|
for (int idx = 0; idx < segments.length; idx++) { |
|
|
|
final String segmentName = segments[idx]; |
|
|
|
if (segmentName.length() > 0) { |
|
|
|
matcher.append("/" + segmentName); |
|
|
|
} |
|
|
|
|
|
|
|
if (matcher.isMatch()) |
|
|
|
if (matcher.isMatch() && |
|
|
|
doesMatchDirectoryExpectations(isDirectory, idx, segments.length)) |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@@ -235,4 +244,14 @@ public class IgnoreRule { |
|
|
|
public boolean getResult() { |
|
|
|
return !negation; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean doesMatchDirectoryExpectations(boolean isDirectory, int segmentIdx, int segmentLength) { |
|
|
|
// The segment we are checking is a directory, expectations are met. |
|
|
|
if (segmentIdx < segmentLength - 1) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
// We are checking the last part of the segment for which isDirectory has to be considered. |
|
|
|
return !dirOnly || isDirectory; |
|
|
|
} |
|
|
|
} |