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;
}
}
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;
}
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;
}
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;
}
Aggregations