James Moger
2012-10-01 22b181154c11cb250a2f7ad9eb7820a462cf3079
src/com/gitblit/GitBlit.java
@@ -82,6 +82,7 @@
import com.gitblit.models.FederationModel;
import com.gitblit.models.FederationProposal;
import com.gitblit.models.FederationSet;
import com.gitblit.models.ForkModel;
import com.gitblit.models.Metric;
import com.gitblit.models.ProjectModel;
import com.gitblit.models.RepositoryModel;
@@ -1403,6 +1404,38 @@
   }
   /**
    * Returns the fork network for a repository by traversing up the fork graph
    * to discover the root and then down through all children of the root node.
    *
    * @param repository
    * @return a ForkModel
    */
   public ForkModel getForkNetwork(String repository) {
      if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {
         // find the root
         RepositoryModel model = repositoryListCache.get(repository);
         while (model.originRepository != null) {
            model = repositoryListCache.get(model.originRepository);
         }
         ForkModel root = getForkModel(model.name);
         return root;
      }
      return null;
   }
   private ForkModel getForkModel(String repository) {
      RepositoryModel model = repositoryListCache.get(repository);
      ForkModel fork = new ForkModel(model.originRepository, model.name);
      if (!ArrayUtils.isEmpty(model.forks)) {
         for (String aFork : model.forks) {
            ForkModel fm = getForkModel(aFork);
            fork.forks.add(fm);
         }
      }
      return fork;
   }
   /**
    * Returns the size in bytes of the repository. Gitblit caches the
    * repository sizes to reduce the performance penalty of recursive
    * calculation. The cache is updated if the repository has been changed