/** * 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; }
LOGGER.log(Level.FINEST, "Checking for comments after: {0}", lastUpdatedTime); try { for (GHIssueComment comment : ghpr.getComments()) { LOGGER.log(Level.FINEST, "Comment was made at: {0}", comment.getUpdatedAt()); if (lastUpdatedTime.compareTo(comment.getUpdatedAt()) < 0) {
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 } }
for (GHIssueComment issueComment : remotePR.getComments()) { if (isNull(localPR) // test all comments for trigger word even if we never saw PR before
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 } }
/** * Lets load the old command context from comments on the PullRequest so that we can re-run a command to rebase things. */ protected CompositeCommand loadCommandsFromPullRequest(CommandContext context, GHRepository ghRepository, GHPullRequest pullRequest) throws IOException { List<GHIssueComment> comments = pullRequest.getComments(); String lastCommand = null; for (GHIssueComment comment : comments) { String command = updateBotCommentCommand(context, comment); if (command != null) { lastCommand = command; } } if (lastCommand == null) { context.warn(LOG, "No UpdateBot comment found on pull request " + pullRequest.getHtmlUrl() + " so cannot rebase!"); return null; } return parseUpdateBotCommandComment(context, lastCommand); }
/** * Lets load the old command context from comments on the PullRequest so that we can re-run a command to rebase things. */ protected CompositeCommand loadCommandsFromPullRequest(CommandContext context, GHRepository ghRepository, GHPullRequest pullRequest) throws IOException { List<GHIssueComment> comments = pullRequest.getComments(); String lastCommand = null; for (GHIssueComment comment : comments) { String command = updateBotCommentCommand(context, comment); if (command != null) { lastCommand = command; } } if (lastCommand == null) { context.warn(LOG, "No UpdateBot comment found on pull request " + pullRequest.getHtmlUrl() + " so cannot rebase!"); return null; } return parseUpdateBotCommandComment(context, lastCommand); }