use of sonia.scm.repository.InternalRepositoryException in project scm-review-plugin by scm-manager.
the class MergeService method createDefaultSquashCommitMessage.
private String createDefaultSquashCommitMessage(NamespaceAndName namespaceAndName, PullRequest pullRequest) {
try (RepositoryService repositoryService = serviceFactory.create(namespaceAndName)) {
if (RepositoryPermissions.read(repositoryService.getRepository()).isPermitted() && repositoryService.isSupported(Command.LOG)) {
try {
StringBuilder builder = new StringBuilder();
Set<Person> contributors = new HashSet<>();
getChangesetsFromLogCommand(pullRequest, repositoryService).forEach(c -> {
contributors.add(c.getAuthor());
builder.append("- ").append(c.getDescription()).append("\n\n");
});
appendSquashContributors(builder, pullRequest, contributors);
return MessageFormat.format(SQUASH_COMMIT_MESSAGE_TEMPLATE, pullRequest.getSource(), pullRequest.getTarget(), builder.toString());
} catch (IOException e) {
throw new InternalRepositoryException(entity("Branch", pullRequest.getSource()).in(repositoryService.getRepository()), "Could not read changesets from repository");
}
} else {
return createDefaultMergeCommitMessage(pullRequest);
}
}
}
use of sonia.scm.repository.InternalRepositoryException 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