use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class RepositoryConfigResource method getRepositoryConfig.
@GET
@Path("{namespace}/{name}/config")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "Repository pull request configuration", description = "Returns the repository-specific pull request configuration.", tags = "Pull Request Configuration", operationId = "review_get_repo_config")
@ApiResponse(responseCode = "200", description = "success", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = PullRequestConfigDto.class)))
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"configurePullRequest\" privilege")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public PullRequestConfigDto getRepositoryConfig(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name) {
Repository repository = repositoryManager.get(new NamespaceAndName(namespace, name));
if (repository == null) {
throw notFound(entity(new NamespaceAndName(namespace, name)));
}
PermissionCheck.checkConfigure(repository);
return repositoryConfigMapper.map(configService.getRepositoryPullRequestConfig(repository), repository, uriInfo);
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class BasicPRMailTextResolver method getMailSubject.
protected String getMailSubject(E event, String displayEventNameKey, Locale locale) {
Repository repository = event.getRepository();
PullRequest pullRequest = event.getPullRequest();
String displayEventName = SUBJECT_BUNDLES.get(locale).getString(displayEventNameKey);
return MessageFormat.format(SUBJECT_PATTERN, repository.getNamespace(), repository.getName(), displayEventName, pullRequest.getId(), pullRequest.getTitle());
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class BasicPRMailTextResolver method getPullRequestLink.
private String getPullRequestLink(String baseUrl, E event) {
Repository repository = event.getRepository();
PullRequest pullRequest = event.getPullRequest();
return MessageFormat.format(SCM_PULL_REQUEST_URL_PATTERN, baseUrl, repository.getNamespace(), repository.getName(), pullRequest.getId());
}
use of sonia.scm.repository.Repository in project scm-review-plugin by scm-manager.
the class PullRequestRootResource method check.
@GET
@Path("{namespace}/{name}/check")
@Produces(PullRequestMediaType.PULL_REQUEST)
@Operation(summary = "Checks pull request", description = "Checks if new pull request can be created.", tags = "Pull Request", operationId = "review_check_pull_request")
@ApiResponse(responseCode = "200", description = "Returns pull request check result")
@ApiResponse(responseCode = "400", description = "Invalid request / the provided source branch or target branch may not exist")
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "403", description = "not authorized, the current user does not have the \"createPullRequest\" privilege")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public PullRequestCheckResultDto check(@Context UriInfo uriInfo, @PathParam("namespace") String namespace, @PathParam("name") String name, @QueryParam("source") String source, @QueryParam("target") String target) throws IOException {
Repository repository = service.getRepository(namespace, name);
PermissionCheck.checkCreate(repository);
service.checkBranch(repository, source);
service.checkBranch(repository, target);
return checkIfPullRequestIsValid(uriInfo, repository, source, target);
}
use of sonia.scm.repository.Repository 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);
}
}
}
}
Aggregations