@IsAllowed(Operation.READ)
public static Result branches(String loginId, String projectName) throws IOException, GitAPIException {
Project project = Project.findByOwnerAndProjectName(loginId, projectName);
GitRepository gitRepository = new GitRepository(project);
List<GitBranch> allBranches = gitRepository.getAllBranches();
final GitBranch headBranch = gitRepository.getHeadBranch();
// filter the head branch from all branch list.
CollectionUtils.filter(allBranches, new Predicate() {
@Override
public boolean evaluate(Object o) {
GitBranch gitBranch = (GitBranch)o;
return !gitBranch.getName().equals(headBranch.getName());
}
});
return ok(branches.render(project, allBranches, headBranch));
}