public String getPullRequestNumber() { return this.issue.isPullRequest() ? this.issue.getNumber() + "" : null; } }
/** * Constructs a release notes message for issue. * @param issue issue. * @param author author. */ public ReleaseNotesMessage(GHIssue issue, String author) { issueNo = issue.getNumber(); title = getActualTitle(issue); this.author = author; }
@Override public String getBranch() { return this.issue.isPullRequest() ? GitBranch.PULL_REQUEST_PREFIX + this.issue.getNumber() : this.repository.getDefaultBranch(); }
public void handleComment(IssueComment issueComment) throws IOException { GhprbRepository repo = getRepository(); LOGGER.log( Level.INFO, "Checking comment on PR #{0} for job {1}", new Object[] {issueComment.getIssue().getNumber(), getProjectName()} ); repo.onIssueCommentHook(issueComment); }
void onIssueCommentHook(IssueComment issueComment) throws IOException { if (!trigger.isActive()) { LOGGER.log(Level.FINE, "Not checking comments since build is disabled"); return; } int number = issueComment.getIssue().getNumber(); LOGGER.log(Level.FINER, "Comment on issue #{0} from {1}: {2}", new Object[] {number, issueComment.getComment().getUser(), issueComment.getComment().getBody()}); if (!"created".equals(issueComment.getAction())) { return; } GhprbPullRequest pull = getPullRequest(null, number); pull.check(issueComment.getComment()); try { this.save(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Unable to save repository!", e); } }
protected PullRequestInfo extractPullRequestInfo(GHEvent event, String payload, GitHub gh) throws IOException { switch (event) { case ISSUE_COMMENT: { GHEventPayload.IssueComment commentPayload = gh.parseEventPayload(new StringReader(payload), GHEventPayload.IssueComment.class); int issueNumber = commentPayload.getIssue().getNumber(); return new PullRequestInfo(commentPayload.getRepository().getFullName(), issueNumber); } case PULL_REQUEST: { GHEventPayload.PullRequest pr = gh.parseEventPayload(new StringReader(payload), GHEventPayload.PullRequest.class); return new PullRequestInfo(pr.getPullRequest().getRepository().getFullName(), pr.getNumber(), pr.getPullRequest().getBase().getRef()); } default: throw new IllegalStateException(format("Did you add event %s in events() method?", event)); } } }
private static StatusInfo createStatus(Configuration configuration, StatusInfo oldStatus) { GHRepository repository = null; GHIssue issue = oldStatus.getIssue(); if (issue != null) { repository = issue.getRepository(); try { issue = repository.getIssue(issue.getNumber()); } catch (IOException e) { configuration.warn(LOG, "Failed to lookup issue " + oldStatus.getIssueUrl() + ". " + e, e); } } GHPullRequest pullRequest = oldStatus.getPullRequest(); if (pullRequest != null) { if (repository == null) { repository = pullRequest.getRepository(); } try { pullRequest = repository.getPullRequest(pullRequest.getNumber()); } catch (IOException e) { configuration.warn(LOG, "Failed to lookup pull request " + oldStatus.getPullRequestUrl() + ". " + e, e); } } return new StatusInfo(oldStatus.getRepository(), oldStatus.getStatus(), issue, pullRequest); }
private static StatusInfo createStatus(Configuration configuration, StatusInfo oldStatus) { GHRepository repository = null; GHIssue issue = oldStatus.getIssue(); if (issue != null) { repository = issue.getRepository(); try { issue = repository.getIssue(issue.getNumber()); } catch (IOException e) { configuration.warn(LOG, "Failed to lookup issue " + oldStatus.getIssueUrl() + ". " + e, e); } } GHPullRequest pullRequest = oldStatus.getPullRequest(); if (pullRequest != null) { if (repository == null) { repository = pullRequest.getRepository(); } try { pullRequest = repository.getPullRequest(pullRequest.getNumber()); } catch (IOException e) { configuration.warn(LOG, "Failed to lookup pull request " + oldStatus.getPullRequestUrl() + ". " + e, e); } } return new StatusInfo(oldStatus.getRepository(), oldStatus.getStatus(), issue, pullRequest); }