if (repositoriesFolder == null || !repositoriesFolder.exists()) {\r
return list;\r
}\r
+ List<Pattern> patterns = new ArrayList<Pattern>();\r
+ if (!ArrayUtils.isEmpty(exclusions)) {\r
+ for (String regex : exclusions) {\r
+ patterns.add(Pattern.compile(regex));\r
+ }\r
+ }\r
list.addAll(getRepositoryList(repositoriesFolder.getAbsolutePath(), repositoriesFolder,\r
- onlyBare, searchSubfolders, depth, exclusions));\r
+ onlyBare, searchSubfolders, depth, patterns));\r
StringUtils.sortRepositorynames(list);\r
return list;\r
}\r
* recurse into subfolders to find grouped repositories\r
* @param depth\r
* recursion depth, -1 = infinite recursion\r
- * @param exclusions\r
- * list of regex exclusions for matching to folder names\r
+ * @param patterns\r
+ * list of regex patterns for matching to folder names\r
* @return\r
*/\r
private static List<String> getRepositoryList(String basePath, File searchFolder,\r
- boolean onlyBare, boolean searchSubfolders, int depth, List<String> exclusions) {\r
+ boolean onlyBare, boolean searchSubfolders, int depth, List<Pattern> patterns) {\r
File baseFile = new File(basePath);\r
List<String> list = new ArrayList<String>();\r
if (depth == 0) {\r
return list;\r
}\r
- List<Pattern> patterns = new ArrayList<Pattern>();\r
- if (!ArrayUtils.isEmpty(exclusions)) {\r
- for (String regex : exclusions) {\r
- patterns.add(Pattern.compile(regex));\r
- }\r
- }\r
\r
int nextDepth = (depth == -1) ? -1 : depth - 1;\r
for (File file : searchFolder.listFiles()) {\r
boolean exclude = false;\r
for (Pattern pattern : patterns) {\r
String path = FileUtils.getRelativePath(baseFile, file).replace('\\', '/');\r
- if (pattern.matcher(path).find()) {\r
+ if (pattern.matcher(path).matches()) {\r
LOGGER.debug(MessageFormat.format("excluding {0} because of rule {1}", path, pattern.pattern()));\r
exclude = true;\r
break;\r
} else if (searchSubfolders && file.canRead()) {\r
// look for repositories in subfolders\r
list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders,\r
- nextDepth, exclusions));\r
+ nextDepth, patterns));\r
}\r
} else if (searchSubfolders && file.canRead()) {\r
// look for repositories in subfolders\r
list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders,\r
- nextDepth, exclusions));\r
+ nextDepth, patterns));\r
}\r
}\r
}\r
list = JGitUtils.getRepositoryList(GitBlitSuite.REPOSITORIES, false, true, -1, Arrays.asList("test/*"));\r
assertFalse("Repository exclusion failed!", list.contains("test/jgit.git"));\r
\r
- list = JGitUtils.getRepositoryList(GitBlitSuite.REPOSITORIES, false, true, -1, Arrays.asList("(jgit)+"));\r
+ list = JGitUtils.getRepositoryList(GitBlitSuite.REPOSITORIES, false, true, -1, Arrays.asList(".*jgit.*"));\r
assertFalse("Repository exclusion failed!", list.contains("test/jgit.git"));\r
assertFalse("Repository exclusion failed!", list.contains("working/jgit"));\r
assertFalse("Repository exclusion failed!", list.contains("working/jgit2"));\r