use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class PullRequestResource method markAsNotReviewed.
@DELETE
@Path("review-mark/{path: .*}")
@Operation(summary = "Unmark as reviewed", description = "Unmarks a diff in a pull request which was before marked as reviewed.", tags = "Pull Request")
@ApiResponse(responseCode = "204", description = "update success")
@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 void markAsNotReviewed(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId, @PathParam("path") String path) {
Repository repository = service.getRepository(namespace, name);
service.markAsNotReviewed(repository, pullRequestId, path);
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class PullRequestResource method markAsReviewed.
@POST
@Path("review-mark/{path: .*}")
@Operation(summary = "Mark as reviewed", description = "Marks a diff in a pull request as reviewed.", tags = "Pull Request")
@ApiResponse(responseCode = "204", description = "update success")
@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 void markAsReviewed(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId, @PathParam("path") String path) {
Repository repository = service.getRepository(namespace, name);
service.markAsReviewed(repository, pullRequestId, path);
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class PullRequestResource method unsubscribe.
@POST
@Path("unsubscribe")
@Operation(summary = "Unsubscribe", description = "Unsubscribes current user from a pull request.", tags = "Pull Request")
@ApiResponse(responseCode = "204", description = "update success")
@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 = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public void unsubscribe(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId) {
Repository repository = service.getRepository(namespace, name);
PermissionCheck.checkRead(repository);
service.unsubscribe(repository, pullRequestId);
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class MergeService method merge.
public void merge(NamespaceAndName namespaceAndName, String pullRequestId, MergeCommitDto mergeCommitDto, MergeStrategy strategy, boolean emergency) {
try (RepositoryService repositoryService = serviceFactory.create(namespaceAndName)) {
PullRequest pullRequest = pullRequestService.get(repositoryService.getRepository(), pullRequestId);
Collection<MergeObstacle> obstacles = verifyNoObstacles(emergency, repositoryService.getRepository(), pullRequest);
assertPullRequestIsOpen(repositoryService.getRepository(), pullRequest);
internalMergeSwitch.runInternalMerge(() -> {
MergeCommandBuilder mergeCommand = repositoryService.getMergeCommand();
isAllowedToMerge(repositoryService.getRepository(), mergeCommand, strategy, emergency);
prepareMergeCommand(repositoryService, mergeCommand, pullRequest, mergeCommitDto, strategy);
MergeCommandResult mergeCommandResult = mergeCommand.executeMerge();
if (!mergeCommandResult.isSuccess()) {
throw new MergeConflictException(namespaceAndName, pullRequest.getSource(), pullRequest.getTarget(), mergeCommandResult);
}
pullRequestService.setRevisions(repositoryService.getRepository(), pullRequest.getId(), mergeCommandResult.getTargetRevision(), mergeCommandResult.getRevisionToMerge());
if (emergency) {
pullRequestService.setEmergencyMerged(repositoryService.getRepository(), pullRequest.getId(), mergeCommitDto.getOverrideMessage(), getIgnoredMergeObstacles(obstacles));
} else {
pullRequestService.setMerged(repositoryService.getRepository(), pullRequest.getId());
}
if (repositoryService.isSupported(Command.BRANCH) && mergeCommitDto.isShouldDeleteSourceBranch()) {
String deletedSourceBranch = pullRequest.getSource();
Repository repository = repositoryService.getRepository();
repositoryService.getBranchCommand().delete(deletedSourceBranch);
rejectPullRequestsForDeletedBranch(repository, pullRequest, deletedSourceBranch);
}
});
}
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class CommentCollectorTest method shouldCollectNonOutdatedComments.
@Test
void shouldCollectNonOutdatedComments() {
Repository repository = RepositoryTestData.createHeartOfGold();
PullRequest pullRequest = TestData.createPullRequest();
Comment one = Comment.createSystemComment("hello");
Comment two = Comment.createSystemComment("hello");
two.setOutdated(true);
List<Comment> prcs = ImmutableList.of(one, two);
when(commentService.getAll(repository.getNamespace(), repository.getName(), pullRequest.getId())).thenReturn(prcs);
Stream<Comment> comments = collector.collectNonOutdated(repository, pullRequest);
assertThat(comments).containsOnly(one);
}
Aggregations