use of org.eclipse.egit.github.core.service.PullRequestService in project pivotal-cla by pivotalsoftware.
the class MylynGitHubApi method getShaForPullRequest.
@SneakyThrows
public String getShaForPullRequest(PullRequestStatus commitStatus) {
String repositoryId = commitStatus.getRepoId();
int pullRequestId = commitStatus.getPullRequestId();
String currentUserGitHubLogin = commitStatus.getGitHubUsername();
String accessToken = commitStatus.getAccessToken();
if (accessToken == null) {
return null;
}
GitHubClient client = createClient(accessToken);
RepositoryId id = RepositoryId.createFromId(repositoryId);
PullRequestService service = new PullRequestService(client);
PullRequest pullRequest = service.getPullRequest(id, pullRequestId);
String githubLoginForContributor = pullRequest.getUser().getLogin();
if (commitStatus.isAdmin()) {
commitStatus.setGitHubUsername(githubLoginForContributor);
} else if (!githubLoginForContributor.equals(currentUserGitHubLogin)) {
return null;
}
return pullRequest.getHead().getSha();
}
Aggregations