Search in sources :

Example 1 with MergeStrategyInfoDto

use of com.cloudogu.scm.review.pullrequest.dto.MergeStrategyInfoDto in project scm-review-plugin by scm-manager.

the class MergeResource method getMergeStrategyInfo.

@GET
@Path("{namespace}/{name}/{pullRequestId}/merge-strategy-info")
@Produces(PullRequestMediaType.MERGE_STRATEGY_INFO)
@Operation(summary = "Get commit message information", description = "Returns commit message information for the given merge strategy", tags = "Pull Request")
@ApiResponse(responseCode = "200", description = "commit message was created", content = @Content(schema = @Schema(implementation = MergeStrategyInfoDto.class)))
@ApiResponse(responseCode = "401", description = "not authenticated / invalid credentials")
@ApiResponse(responseCode = "500", description = "internal server error", content = @Content(mediaType = VndMediaType.ERROR_TYPE, schema = @Schema(implementation = ErrorDto.class)))
public MergeStrategyInfoDto getMergeStrategyInfo(@PathParam("namespace") String namespace, @PathParam("name") String name, @PathParam("pullRequestId") String pullRequestId, @QueryParam("strategy") MergeStrategy strategy) {
    MergeService.CommitDefaults commitDefaults = service.createCommitDefaults(new NamespaceAndName(namespace, name), pullRequestId, strategy);
    DisplayUser commitAuthor = commitDefaults.getCommitAuthor();
    return new MergeStrategyInfoDto(service.isCommitMessageDisabled(strategy), commitDefaults.getCommitMessage(), service.createMergeCommitMessageHint(strategy), renderCommitAuthorIfPresent(commitAuthor));
}
Also used : MergeService(com.cloudogu.scm.review.pullrequest.service.MergeService) NamespaceAndName(sonia.scm.repository.NamespaceAndName) DisplayUser(sonia.scm.user.DisplayUser) MergeStrategyInfoDto(com.cloudogu.scm.review.pullrequest.dto.MergeStrategyInfoDto) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponse(io.swagger.v3.oas.annotations.responses.ApiResponse)

Aggregations

MergeStrategyInfoDto (com.cloudogu.scm.review.pullrequest.dto.MergeStrategyInfoDto)1 MergeService (com.cloudogu.scm.review.pullrequest.service.MergeService)1 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 NamespaceAndName (sonia.scm.repository.NamespaceAndName)1 DisplayUser (sonia.scm.user.DisplayUser)1