首页 > 解决方案 > 使用 github-java sdk 添加审阅者到拉取请求

问题描述

我正在尝试使用https://github.com/eclipse/egit-github/tree/master/org.eclipse.egit.github.core创建拉取请求,但找不到向拉取请求添加评论的方法。V3 Github API 支持添加此处提到的审阅者,https://developer.github.com/v3/pulls/review_requests/#create-a-review-request。我正在尝试按如下方式创建拉取请求。

private void createPullRequest(
        String repositoryName,
        String repositoryOwner,
        String pullRequestTitle,
        String pullRequestBody,
        String branchSource,
        String branchDestination
) throws IOException {

    logger.info("starting to create pull request");

    var gitHubClient = new GitHubClient();
    gitHubClient.setCredentials("x", "y");
    var repositoryService = new RepositoryService(gitHubClient);
    var repository = repositoryService.getRepository(repositoryOwner, repositoryName);

    var pullRequestService = new PullRequestService(gitHubClient);
    var pullRequest = new PullRequest();
    pullRequest.setTitle(pullRequestTitle);
    pullRequest.setBody(pullRequestBody);

    pullRequest.setHead(
            new PullRequestMarker().setRef(branchSource).setLabel(branchSource)
    );

    pullRequest.setBase(
            new PullRequestMarker().setRef(branchDestination).setLabel(branchDestination)
    );

    logger.info("Finally starting to push PR");

    pullRequestService.createPullRequest(repository, pullRequest);

    logger.info("PR should be created now");
}

从它说的文档来看,它支持 100% 的 Github V3 API。但是我无法在代码和在线中找到任何用于添加审阅者的参考。

谢谢!

标签: javagithub-api

解决方案


推荐阅读