use of io.pivotal.cla.egit.github.core.service.ContextCommitService in project pivotal-cla by pivotalsoftware.
the class MylynGitHubApi method createCommitStatusIfNecessary.
private ContextCommitStatus createCommitStatusIfNecessary(PullRequestId pullRequestId, PullRequestStatus commitStatus, boolean hasSignedCla, boolean obviousFix, GitHubClient client) {
ContextCommitService commitService = new ContextCommitService(client);
ContextCommitStatus status = new ContextCommitStatus();
String description;
if (obviousFix) {
description = OBVIOUS_FIX_CLA_NOT_REQUIRED;
} else if (hasSignedCla) {
description = String.format("%s %s!", THANK_YOU, CONTRIBUTOR_LICENSE_AGREEMENT);
} else {
description = String.format("%s %s!", PLEASE_SIGN, CONTRIBUTOR_LICENSE_AGREEMENT);
}
status.setDescription(description);
status.setState((hasSignedCla || obviousFix) ? CommitStatus.STATE_SUCCESS : CommitStatus.STATE_FAILURE);
status.setContext("ci/pivotal-cla");
status.setUrl(commitStatus.getUrl());
status.setTargetUrl(status.getUrl());
List<ContextCommitStatus> statuses = commitService.getContextStatuses(pullRequestId.getRepositoryId(), commitStatus.getSha());
if (!statuses.stream().anyMatch(s -> matches(status, s))) {
commitService.createStatus(pullRequestId.getRepositoryId(), commitStatus.getSha(), status);
}
return status;
}
Aggregations