diff options
author | James Moger <james.moger@gitblit.com> | 2012-08-01 09:48:06 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2012-08-01 09:48:06 -0400 |
commit | 65f55eee1c41a9cdfec96dc4310efcc6e57df97f (patch) | |
tree | bd5d6d65af03f750f3b984b5ccf7f56cb95d66fd /src/com | |
parent | 874be0d933eb52d548a07b67d112a0975e900b14 (diff) | |
download | gitblit-65f55eee1c41a9cdfec96dc4310efcc6e57df97f.tar.gz gitblit-65f55eee1c41a9cdfec96dc4310efcc6e57df97f.zip |
Add recursion depth control for repository search (issue 103)
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/gitblit/AddIndexedBranch.java | 2 | ||||
-rw-r--r-- | src/com/gitblit/GitBlit.java | 3 | ||||
-rw-r--r-- | src/com/gitblit/utils/JGitUtils.java | 18 |
3 files changed, 16 insertions, 7 deletions
diff --git a/src/com/gitblit/AddIndexedBranch.java b/src/com/gitblit/AddIndexedBranch.java index 1eb93891..8ead17e0 100644 --- a/src/com/gitblit/AddIndexedBranch.java +++ b/src/com/gitblit/AddIndexedBranch.java @@ -63,7 +63,7 @@ public class AddIndexedBranch { // determine available repositories
File folder = new File(params.folder);
- List<String> repoList = JGitUtils.getRepositoryList(folder, false, true);
+ List<String> repoList = JGitUtils.getRepositoryList(folder, false, true, -1);
int modCount = 0;
int skipCount = 0;
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index 10b12534..d4a59d5a 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -742,7 +742,8 @@ public class GitBlit implements ServletContextListener { public List<String> getRepositoryList() {
return JGitUtils.getRepositoryList(repositoriesFolder,
settings.getBoolean(Keys.git.onlyAccessBareRepositories, false),
- settings.getBoolean(Keys.git.searchRepositoriesSubfolders, true));
+ settings.getBoolean(Keys.git.searchRepositoriesSubfolders, true),
+ settings.getInteger(Keys.git.searchRecursionDepth, -1));
}
/**
diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java index 62d27da8..ff701b39 100644 --- a/src/com/gitblit/utils/JGitUtils.java +++ b/src/com/gitblit/utils/JGitUtils.java @@ -275,16 +275,18 @@ public class JGitUtils { * false all repositories are included.
* @param searchSubfolders
* recurse into subfolders to find grouped repositories
+ * @param depth
+ * optional recursion depth, -1 = infinite recursion
* @return list of repository names
*/
public static List<String> getRepositoryList(File repositoriesFolder, boolean onlyBare,
- boolean searchSubfolders) {
+ boolean searchSubfolders, int depth) {
List<String> list = new ArrayList<String>();
if (repositoriesFolder == null || !repositoriesFolder.exists()) {
return list;
}
list.addAll(getRepositoryList(repositoriesFolder.getAbsolutePath(), repositoriesFolder,
- onlyBare, searchSubfolders));
+ onlyBare, searchSubfolders, depth));
StringUtils.sortRepositorynames(list);
return list;
}
@@ -301,12 +303,18 @@ public class JGitUtils { * repositories are included.
* @param searchSubfolders
* recurse into subfolders to find grouped repositories
+ * @param depth
+ * recursion depth, -1 = infinite recursion
* @return
*/
private static List<String> getRepositoryList(String basePath, File searchFolder,
- boolean onlyBare, boolean searchSubfolders) {
+ boolean onlyBare, boolean searchSubfolders, int depth) {
File baseFile = new File(basePath);
List<String> list = new ArrayList<String>();
+ if (depth == 0) {
+ return list;
+ }
+ int nextDepth = (depth == -1) ? -1 : depth - 1;
for (File file : searchFolder.listFiles()) {
if (file.isDirectory()) {
File gitDir = FileKey.resolve(new File(searchFolder, file.getName()), FS.DETECTED);
@@ -320,11 +328,11 @@ public class JGitUtils { list.add(repository);
} else if (searchSubfolders && file.canRead()) {
// look for repositories in subfolders
- list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders));
+ list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders, nextDepth));
}
} else if (searchSubfolders && file.canRead()) {
// look for repositories in subfolders
- list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders));
+ list.addAll(getRepositoryList(basePath, file, onlyBare, searchSubfolders, nextDepth));
}
}
}
|