summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-01-02 16:35:16 -0500
committerJames Moger <james.moger@gitblit.com>2013-01-02 16:35:16 -0500
commit9910e56056d2f2639d2783257ae9f1bf46aaee58 (patch)
tree2ee329a8e74c43d9e1ef7ee2f6454987522b2f7f
parent46bdf9829d62a296c66c8a15969308838ea8cbe9 (diff)
downloadgitblit-9910e56056d2f2639d2783257ae9f1bf46aaee58.tar.gz
gitblit-9910e56056d2f2639d2783257ae9f1bf46aaee58.zip
Fixed fork origin determination if !git.cacheRepositoryList (issue-182)
-rw-r--r--src/com/gitblit/GitBlit.java25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java
index b497737f..3dcd5a09 100644
--- a/src/com/gitblit/GitBlit.java
+++ b/src/com/gitblit/GitBlit.java
@@ -1760,22 +1760,41 @@ public class GitBlit implements ServletContextListener {
*/
public ForkModel getForkNetwork(String repository) {
if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {
- // find the root
+ // find the root, cached
RepositoryModel model = repositoryListCache.get(repository.toLowerCase());
while (model.originRepository != null) {
model = repositoryListCache.get(model.originRepository);
}
+ ForkModel root = getForkModelFromCache(model.name);
+ return root;
+ } else {
+ // find the root, non-cached
+ RepositoryModel model = getRepositoryModel(repository.toLowerCase());
+ while (model.originRepository != null) {
+ model = getRepositoryModel(model.originRepository);
+ }
ForkModel root = getForkModel(model.name);
return root;
}
- return null;
}
- private ForkModel getForkModel(String repository) {
+ private ForkModel getForkModelFromCache(String repository) {
RepositoryModel model = repositoryListCache.get(repository.toLowerCase());
ForkModel fork = new ForkModel(model);
if (!ArrayUtils.isEmpty(model.forks)) {
for (String aFork : model.forks) {
+ ForkModel fm = getForkModelFromCache(aFork);
+ fork.forks.add(fm);
+ }
+ }
+ return fork;
+ }
+
+ private ForkModel getForkModel(String repository) {
+ RepositoryModel model = getRepositoryModel(repository.toLowerCase());
+ ForkModel fork = new ForkModel(model);
+ if (!ArrayUtils.isEmpty(model.forks)) {
+ for (String aFork : model.forks) {
ForkModel fm = getForkModel(aFork);
fork.forks.add(fm);
}