From 9910e56056d2f2639d2783257ae9f1bf46aaee58 Mon Sep 17 00:00:00 2001 From: James Moger <james.moger@gitblit.com> Date: Wed, 02 Jan 2013 16:35:16 -0500 Subject: [PATCH] Fixed fork origin determination if !git.cacheRepositoryList (issue-182) --- src/com/gitblit/GitBlit.java | 25 ++++++++++++++++++++++--- 1 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index b497737..3dcd5a0 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -1760,19 +1760,38 @@ */ 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 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 = repositoryListCache.get(repository.toLowerCase()); + RepositoryModel model = getRepositoryModel(repository.toLowerCase()); ForkModel fork = new ForkModel(model); if (!ArrayUtils.isEmpty(model.forks)) { for (String aFork : model.forks) { -- Gitblit v1.9.1