use of sonia.scm.repository.api.BranchesCommandBuilder in project scm-review-plugin by scm-manager.
the class BranchRevisionResolverTest method setUpBranches.
private void setUpBranches(String... names) throws IOException {
when(repositoryService.getBranchesCommand()).thenReturn(branchesCommandBuilder);
List<Branch> branches = Arrays.stream(names).map(name -> Branch.normalBranch(name, name)).collect(Collectors.toList());
when(branchesCommandBuilder.getBranches()).thenReturn(new Branches(branches));
}
use of sonia.scm.repository.api.BranchesCommandBuilder in project scm-review-plugin by scm-manager.
the class BranchResolver method resolve.
public Branch resolve(Repository repository, String branchName) {
try (RepositoryService repositoryService = repositoryServiceFactory.create(repository)) {
BranchesCommandBuilder branchesCommand = repositoryService.getBranchesCommand();
List<Branch> allBranches = branchesCommand.getBranches().getBranches();
return allBranches.stream().filter(b -> b.getName().equals(branchName)).findFirst().orElseThrow(() -> notFound(entity("branch", branchName).in(repository)));
} catch (IOException e) {
throw new InternalRepositoryException(repository, "could not read branches", e);
}
}
Aggregations