public List<String> getRepositoryList() {\r
return JGitUtils.getRepositoryList(repositoriesFolder, \r
settings.getBoolean(Keys.git.onlyAccessBareRepositories, false),\r
- settings.getBoolean(Keys.git.searchRepositoriesSubfolders, true));\r
+ settings.getBoolean(Keys.git.searchRepositoriesSubfolders, true),\r
+ settings.getInteger(Keys.git.searchRecursionDepth, -1));\r
}\r
\r
/**\r
* false all repositories are included.\r
* @param searchSubfolders\r
* recurse into subfolders to find grouped repositories\r
+ * @param depth\r
+ * optional recursion depth, -1 = infinite recursion\r
* @return list of repository names\r
*/\r
public static List<String> getRepositoryList(File repositoriesFolder, boolean onlyBare,\r
- boolean searchSubfolders) {\r
+ boolean searchSubfolders, int depth) {\r
List<String> list = new ArrayList<String>();\r
if (repositoriesFolder == null || !repositoriesFolder.exists()) {\r
return list;\r
}\r
list.addAll(getRepositoryList(repositoriesFolder.getAbsolutePath(), repositoriesFolder,\r
- onlyBare, searchSubfolders));\r
+ onlyBare, searchSubfolders, depth));\r
StringUtils.sortRepositorynames(list);\r
return list;\r
}\r
* repositories are included.\r
* @param searchSubfolders\r
* recurse into subfolders to find grouped repositories\r
+ * @param depth\r
+ * recursion depth, -1 = infinite recursion\r
* @return\r
*/\r
private static List<String> getRepositoryList(String basePath, File searchFolder,\r
- boolean onlyBare, boolean searchSubfolders) {\r
+ boolean onlyBare, boolean searchSubfolders, int depth) {\r
File baseFile = new File(basePath);\r
List<String> list = new ArrayList<String>();\r
+ if (depth == 0) {\r
+ return list;\r
+ }\r
+ int nextDepth = (depth == -1) ? -1 : depth - 1;\r
for (File file : searchFolder.listFiles()) {\r
if (file.isDirectory()) {\r
File gitDir = FileKey.resolve(new File(searchFolder, file.getName()), FS.DETECTED);\r
list.add(repository);\r
} else if (searchSubfolders && file.canRead()) {\r
// look for repositories in subfolders\r
- list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders));\r
+ list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders, nextDepth));\r
}\r
} else if (searchSubfolders && file.canRead()) {\r
// look for repositories in subfolders\r
- list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders));\r
+ list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders, nextDepth));\r
}\r
}\r
}\r
\r
@Test\r
public void testFindRepositories() {\r
- List<String> list = JGitUtils.getRepositoryList(null, false, true);\r
+ List<String> list = JGitUtils.getRepositoryList(null, false, true, -1);\r
assertEquals(0, list.size());\r
- list.addAll(JGitUtils.getRepositoryList(new File("DoesNotExist"), true, true));\r
+ list.addAll(JGitUtils.getRepositoryList(new File("DoesNotExist"), true, true, -1));\r
assertEquals(0, list.size());\r
- list.addAll(JGitUtils.getRepositoryList(GitBlitSuite.REPOSITORIES, false, true));\r
+ list.addAll(JGitUtils.getRepositoryList(GitBlitSuite.REPOSITORIES, false, true, -1));\r
assertTrue("No repositories found in " + GitBlitSuite.REPOSITORIES, list.size() > 0);\r
}\r
\r