/** * Checks whether the specific PR contains a comment with the expected body. * * @return true if the PR contains comment with the specified body, otherwise false */ private boolean containsComment(GHPullRequest ghPullRequest, String expectedBody) { List<GHIssueComment> prComments; try { prComments = ghPullRequest.getComments(); } catch (IOException e) { LOGGER.log(Level.WARNING, "Failed to get comments for PR " + ghPullRequest, e); // return false in case of an error - probably safer to have multiple comments than possibly none return false; } for (GHIssueComment comment : prComments) { if (comment.getBody() != null && comment.getBody().equals(expectedBody)) { return true; } } return false; }
public String getDescription() { return StringUtils.abbreviate(this.comment.getBody(), 40); }
private boolean findAndDeleteOthers(@Nullable String markup) throws IOException { boolean found = false; for (GHIssueComment comment : pr.listComments()) { if (myself.equals(comment.getUser().getLogin())) { if (markup == null || found || !markup.equals(comment.getBody())) { comment.delete(); continue; } if (markup.equals(comment.getBody())) { found = true; } } } return found; }
private GitHubPRCause checkComment(GitHubPRDecisionContext prDecisionContext, GHIssueComment issueComment, GitHubPRUserRestriction userRestriction, TaskListener listener) { GitHubPRCause cause = null; try { String body = issueComment.getBody(); if (isNull(userRestriction) || userRestriction.isWhitelisted(issueComment.getUser())) { final Matcher matcher = Pattern.compile(comment).matcher(body); if (matcher.matches()) { listener.getLogger().println(DISPLAY_NAME + ": matching comment " + body); LOG.trace("Event matches comment '{}'", body); cause = prDecisionContext.newCause("Comment matches to criteria.", false); cause.withCommentBody(body); if (matcher.groupCount() > 0) { cause.withCommentBodyMatch(matcher.group(1)); } } } } catch (IOException ex) { LOG.error("Couldn't check comment #{}, skipping it.", issueComment.getId(), ex); } return cause; }
LOGGER.log(Level.FINEST, "Comment was made at: {0}", comment.getUpdatedAt()); if (lastUpdatedTime.compareTo(comment.getUpdatedAt()) < 0) { LOGGER.log(Level.FINEST, "Comment was made after last update time, {0}", comment.getBody()); count++; try {
public static String updateBotIssuePendingChangesComment(CommandContext context, GHIssueComment comment) throws IOException { GHUser user = comment.getUser(); if (user != null) { if (Objects.equal(context.getConfiguration().getGithubUsername(), user.getLogin())) { String body = comment.getBody(); if (body != null) { body = body.trim(); if (body.startsWith(PENDING_CHANGE_COMMENT_PREFIX)) { return body; } } } } return null; }
private String updateBotCommentCommand(CommandContext context, GHIssueComment comment) throws IOException { GHUser user = comment.getUser(); if (user != null) { if (Objects.equal(context.getConfiguration().getGithubUsername(), user.getLogin())) { String body = comment.getBody(); if (body != null) { body = body.trim(); if (body.startsWith(PullRequests.COMMAND_COMMENT_PREFIX)) { return body; } } } } return null; }
private String updateBotCommentCommand(CommandContext context, GHIssueComment comment) throws IOException { GHUser user = comment.getUser(); if (user != null) { if (Objects.equal(context.getConfiguration().getGithubUsername(), user.getLogin())) { String body = comment.getBody(); if (body != null) { body = body.trim(); if (body.startsWith(PullRequests.COMMAND_COMMENT_PREFIX)) { return body; } } } } return null; }
public static String updateBotIssuePendingChangesComment(CommandContext context, GHIssueComment comment) throws IOException { GHUser user = comment.getUser(); if (user != null) { if (Objects.equal(context.getConfiguration().getGithubUsername(), user.getLogin())) { String body = comment.getBody(); if (body != null) { body = body.trim(); if (body.startsWith(PENDING_CHANGE_COMMENT_PREFIX)) { return body; } } } } return null; }
private void addIssueClosedCommentIfRequired(CommandContext context, GHPullRequest pullRequest, boolean create) { GHIssue issue = context.getIssue(); if (issue == null) { return; } if (!create) { // avoid duplicate comment try { List<GHIssueComment> comments = pullRequest.getComments(); for (GHIssueComment comment : comments) { String body = comment.getBody(); if (body != null && body.startsWith(PullRequests.ISSUE_LINK_COMMENT)) { return; } } } catch (IOException e) { // ignore } } try { pullRequest.comment(PullRequests.ISSUE_LINK_COMMENT + " " + issue.getHtmlUrl() + PullRequests.ISSUE_LINK_COMMENT_SUFFIX); } catch (IOException e) { // ignore } }
DISPLAY_NAME, issueComment.getBody());
private void addIssueClosedCommentIfRequired(CommandContext context, GHPullRequest pullRequest, boolean create) { GHIssue issue = context.getIssue(); if (issue == null) { return; } if (!create) { // avoid duplicate comment try { List<GHIssueComment> comments = pullRequest.getComments(); for (GHIssueComment comment : comments) { String body = comment.getBody(); if (body != null && body.startsWith(PullRequests.ISSUE_LINK_COMMENT)) { return; } } } catch (IOException e) { // ignore } } try { pullRequest.comment(PullRequests.ISSUE_LINK_COMMENT + " " + issue.getHtmlUrl() + PullRequests.ISSUE_LINK_COMMENT_SUFFIX); } catch (IOException e) { // ignore } }
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); } }
private void checkComment(GHIssueComment comment) throws IOException { GHUser sender = comment.getUser(); String body = comment.getBody();
new Object[] {comment.getComment().getBody(), repoName});