public BranchDto getBranch(ProjectDto project, String name) {
    if (project.hasBranch(name) == false) {
      repo.loadProjectBranches(project);
    }

    if (project.hasBranch(name) == false) {
      getProjectBranches(project);
    }
    return project.getBranch(name);
  }
  private void getProjectBranches(ProjectDto project) {
    List<BranchInfo> branches = null;
    try {
      ProjectApi.ListBranchesRequest request = api.projects().name(project.projectId).branches();
      branches = caller.waitOrCall(() -> request.get());
    } catch (Exception e) {
      logger.error(Logging.prepare("getProjectBranches", project.projectId), e);
    }

    if (branches != null) {
      List<BranchDto> projectBranches =
          branches
              .stream()
              .filter(b -> project.hasBranch(b.ref) == false)
              .map(b -> repo.addBranch(project, b.ref, b.revision))
              .filter(b -> b != null)
              .collect(Collectors.toList());

      projectBranches.forEach(project.branches::add);
    }
  }