use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class PullRequestMapper method appendMergeStrategyLinks.
private void appendMergeStrategyLinks(Links.Builder linksBuilder, Repository repository, PullRequest pullRequest) {
try (RepositoryService service = serviceFactory.create(repository)) {
if (service.isSupported(Command.MERGE)) {
List<Link> mergeStrategyLinks = service.getMergeCommand().getSupportedMergeStrategies().stream().map(strategy -> createMergeStrategyLink(repository.getNamespaceAndName(), pullRequest, strategy)).collect(toList());
linksBuilder.array(mergeStrategyLinks);
if (PermissionCheck.mayPerformEmergencyMerge(repository)) {
List<Link> emergencyMergeStrategyLinks = service.getMergeCommand().getSupportedMergeStrategies().stream().map(strategy -> createEmergencyMergeStrategyLink(repository.getNamespaceAndName(), pullRequest, strategy)).collect(toList());
linksBuilder.array(emergencyMergeStrategyLinks);
}
}
}
}
use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class PullRequestResource method events.
@GET
@Path("events")
@SseResponse
@Operation(summary = "Register SSE", hidden = true)
@Produces(MediaType.SERVER_SENT_EVENTS)
public void events(@Context Sse sse, @Context SseEventSink eventSink, @BeanParam EventSubscriptionRequest request) {
Repository repository = service.getRepository(request.getNamespace(), request.getName());
PermissionCheck.checkRead(repository);
PullRequest pullRequest = service.get(repository, request.getPullRequestId());
Channel channel = channelRegistry.channel(new ChannelId(repository, pullRequest));
channel.register(new Registration(request.getSessionId(), sse, eventSink));
}
use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class PullRequestResource method update.
@PUT
@Path("")
@Consumes(PullRequestMediaType.PULL_REQUEST)
@Operation(summary = "Update pull request", description = "Modifies a pull request.", tags = "Pull Request", operationId = "review_put_pull_request")
@ApiResponse(responseCode = "204", description = "update success")
@ApiResponse(responseCode = "400", description = "Invalid body")
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"modifyPullRequest\" privilege")
@ApiResponse(responseCode = "404", description = "not found, no pull request with the specified id is available")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public Response update(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId, PullRequestDto pullRequestDto) {
Repository repository = service.getRepository(namespace, name);
if (!PermissionCheck.mayModifyPullRequest(repository, service.get(namespace, name, pullRequestId))) {
return Response.status(Response.Status.FORBIDDEN).build();
}
PullRequest pullRequest = mapper.map(pullRequestDto);
service.update(repository, pullRequestId, pullRequest);
return Response.noContent().build();
}
use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class AllTasksDoneRule method getComments.
private List<Comment> getComments(Context context) {
Repository repository = context.getRepository();
PullRequest pullRequest = context.getPullRequest();
return commentService.getAll(repository.getNamespace(), repository.getName(), pullRequest.getId());
}
use of com.cloudogu.scm.review.pullrequest.service.PullRequest in project scm-review-plugin by scm-manager.
the class ApprovedByXReviewersRule method validate.
@Override
public Result validate(Context context) {
final PullRequest pullRequest = context.getPullRequest();
Configuration configuration = context.getConfiguration(Configuration.class);
long numberOfReviewers = pullRequest.getReviewer().values().stream().filter(b -> b).count();
return numberOfReviewers >= configuration.numberOfReviewers ? success() : failed(new ErrorContext(configuration.numberOfReviewers, (int) numberOfReviewers, (int) (configuration.numberOfReviewers - numberOfReviewers)));
}
Aggregations