Search in sources :

Example 1 with CreateGitReference

use of com.meisolsson.githubsdk.model.request.git.CreateGitReference in project gh4a by slapperwan.

the class PullRequestFragment method restorePullRequestBranch.

private void restorePullRequestBranch() {
    PullRequestMarker head = mPullRequest.head();
    if (head.repo() == null) {
        return;
    }
    String owner = head.repo().owner().login();
    String repo = head.repo().name();
    GitService service = ServiceFactory.get(GitService.class, false);
    CreateGitReference request = CreateGitReference.builder().ref("refs/heads/" + head.ref()).sha(head.sha()).build();
    service.createGitReference(owner, repo, request).map(ApiHelpers::throwOnFailure).compose(RxUtils.wrapForBackgroundTask(getBaseActivity(), R.string.saving_msg, R.string.restore_branch_error)).subscribe(result -> {
        mHeadReference = result;
        onHeadReferenceUpdated();
    }, error -> handleActionFailure("Restoring PR branch failed", error));
}
Also used : GitService(com.meisolsson.githubsdk.service.git.GitService) ApiHelpers(com.gh4a.utils.ApiHelpers) PullRequestMarker(com.meisolsson.githubsdk.model.PullRequestMarker) CreateGitReference(com.meisolsson.githubsdk.model.request.git.CreateGitReference)

Aggregations

ApiHelpers (com.gh4a.utils.ApiHelpers)1 PullRequestMarker (com.meisolsson.githubsdk.model.PullRequestMarker)1 CreateGitReference (com.meisolsson.githubsdk.model.request.git.CreateGitReference)1 GitService (com.meisolsson.githubsdk.service.git.GitService)1