Search in sources :

Example 1 with ForkModel

use of com.gitblit.models.ForkModel in project gitblit by gitblit.

the class RepositoryManager method getForkNetwork.

/**
	 * 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
	 */
@Override
public ForkModel getForkNetwork(String repository) {
    if (settings.getBoolean(Keys.git.cacheRepositoryList, true)) {
        // find the root, cached
        String key = getRepositoryKey(repository);
        RepositoryModel model = repositoryListCache.get(key);
        if (model == null) {
            return null;
        }
        while (model.originRepository != null) {
            String originKey = getRepositoryKey(model.originRepository);
            model = repositoryListCache.get(originKey);
            if (model == null) {
                return null;
            }
        }
        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;
    }
}
Also used : ForkModel(com.gitblit.models.ForkModel) RepositoryModel(com.gitblit.models.RepositoryModel)

Example 2 with ForkModel

use of com.gitblit.models.ForkModel in project gitblit by gitblit.

the class ForksPage method flatten.

protected List<FlatFork> flatten(ForkModel node, int level) {
    List<FlatFork> list = new ArrayList<FlatFork>();
    if (node == null) {
        return list;
    }
    list.add(new FlatFork(node.repository, level));
    if (!node.isLeaf()) {
        for (ForkModel fork : node.forks) {
            list.addAll(flatten(fork, level + 1));
        }
    }
    return list;
}
Also used : ForkModel(com.gitblit.models.ForkModel) ArrayList(java.util.ArrayList)

Example 3 with ForkModel

use of com.gitblit.models.ForkModel in project gitblit by gitblit.

the class RepositoryManager method getForkModel.

private ForkModel getForkModel(String repository) {
    RepositoryModel model = getRepositoryModel(repository.toLowerCase());
    if (model == null) {
        return null;
    }
    ForkModel fork = new ForkModel(model);
    if (!ArrayUtils.isEmpty(model.forks)) {
        for (String aFork : model.forks) {
            ForkModel fm = getForkModel(aFork);
            if (fm != null) {
                fork.forks.add(fm);
            }
        }
    }
    return fork;
}
Also used : ForkModel(com.gitblit.models.ForkModel) RepositoryModel(com.gitblit.models.RepositoryModel)

Example 4 with ForkModel

use of com.gitblit.models.ForkModel in project gitblit by gitblit.

the class RepositoryManager method getForkModelFromCache.

private ForkModel getForkModelFromCache(String repository) {
    String key = getRepositoryKey(repository);
    RepositoryModel model = repositoryListCache.get(key);
    if (model == null) {
        return null;
    }
    ForkModel fork = new ForkModel(model);
    if (!ArrayUtils.isEmpty(model.forks)) {
        for (String aFork : model.forks) {
            ForkModel fm = getForkModelFromCache(aFork);
            if (fm != null) {
                fork.forks.add(fm);
            }
        }
    }
    return fork;
}
Also used : ForkModel(com.gitblit.models.ForkModel) RepositoryModel(com.gitblit.models.RepositoryModel)

Aggregations

ForkModel (com.gitblit.models.ForkModel)4 RepositoryModel (com.gitblit.models.RepositoryModel)3 ArrayList (java.util.ArrayList)1