Search in sources :

Example 1 with MergeRequest

use of com.meisolsson.githubsdk.model.request.pull_request.MergeRequest in project gh4a by slapperwan.

the class PullRequestActivity method mergePullRequest.

private void mergePullRequest(String commitMessage, MergeRequest.Method mergeMethod) {
    String errorMessage = getString(R.string.pull_error_merge, mPullRequest.number());
    PullRequestService service = ServiceFactory.get(PullRequestService.class, false);
    MergeRequest request = MergeRequest.builder().commitMessage(commitMessage).method(mergeMethod).build();
    service.mergePullRequest(mRepoOwner, mRepoName, mPullRequestNumber, request).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(this, R.string.merging_msg, errorMessage)).subscribe(result -> {
        if (result.merged()) {
            mPullRequest = mPullRequest.toBuilder().merged(true).state(IssueState.Closed).build();
        }
        handlePullRequestUpdate();
    }, error -> handleActionFailure("Merging pull request failed", error));
}
Also used : PullRequestService(com.meisolsson.githubsdk.service.pull_request.PullRequestService) MergeRequest(com.meisolsson.githubsdk.model.request.pull_request.MergeRequest) ApiHelpers(com.gh4a.utils.ApiHelpers)

Aggregations

ApiHelpers (com.gh4a.utils.ApiHelpers)1 MergeRequest (com.meisolsson.githubsdk.model.request.pull_request.MergeRequest)1 PullRequestService (com.meisolsson.githubsdk.service.pull_request.PullRequestService)1