@Override public Collection<GHLabel> getLabels() throws IOException { fetchIssue(); return super.getLabels(); }
public String getPullRequestNumber() { return this.issue.isPullRequest() ? this.issue.getNumber() + "" : null; } }
protected static GHIssueState state(GHIssue issue) { if (issue != null) { return issue.getState(); } return null; }
private void _addLabels(Collection<String> names) throws IOException { List<String> newLabels = new ArrayList<String>(); for (GHLabel label : getLabels()) { newLabels.add(label.getName()); } for (String name : names) { if (!newLabels.contains(name)) { newLabels.add(name); } } setLabels(newLabels.toArray(new String[0])); }
public static List<DependencyVersionChange> loadPendingChangesFromIssue(CommandContext context, GHIssue issue) throws IOException { List<GHIssueComment> comments = issue.getComments(); String lastCommand = null; for (GHIssueComment comment : comments) { String command = updateBotIssuePendingChangesComment(context, comment); if (command != null) { lastCommand = command; } } if (lastCommand == null) { LOG.warn("No UpdateBot comment found on issue " + issue.getHtmlUrl()); return new ArrayList<>(); } return parseUpdateBotIssuePendingChangesComment(lastCommand); }
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); }
if (currentPendingChanges.isEmpty()) { if (issue != null) { context.info(LOG, "Closing issue as we have no further pending issues " + issue.getHtmlUrl()); issue.comment(Issues.CLOSE_MESSAGE + operationDescrption); issue.close(); issue = Issues.createIssue(context, ghRepository); context.setIssue(issue); context.info(LOG, configuration.colored(Configuration.COLOR_PENDING, "Created issue " + issue.getHtmlUrl())); } else { context.info(LOG, configuration.colored(Configuration.COLOR_PENDING, "Modifying issue " + issue.getHtmlUrl()));
/** * 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; }
GHIssueState state = comment.getIssue().getState(); if (!comment.getIssue().isPullRequest()) { LOGGER.log(Level.INFO, "Skip comment on Issue"); return;
@Override public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException { if (getStatusVerifier() != null && !getStatusVerifier().isRunAllowed(run)) { return; } String publishedURL = getTriggerDescriptor().getPublishedURL(); if (publishedURL != null && !publishedURL.isEmpty()) { try { if (getGhIssue(run).getState().equals(GHIssueState.OPEN)) { try { getGhPullRequest(run).close(); } catch (IOException ex) { LOGGER.error("Couldn't close the pull request #{}:", getPRNumberFromPRCause(run), ex); } } } catch (IOException ex) { listener.getLogger().println("Can't close pull request \n" + ex); handlePublisherError(run); } } }
public FormValidation doTestComment( @QueryParameter("serverAPIUrl") final String serverAPIUrl, @QueryParameter("credentialsId") final String credentialsId, @QueryParameter("repo") final String repoName, @QueryParameter("issueId") final int issueId, @QueryParameter("message1") final String comment) { try { GitHubBuilder builder = getBuilder(null, serverAPIUrl, credentialsId); if (builder == null) { return FormValidation.error("Unable to look up GitHub credentials using ID: " + credentialsId + "!!"); } GitHub gh = builder.build(); GHRepository repo = gh.getRepository(repoName); GHIssue issue = repo.getIssue(issueId); issue.comment(comment); return FormValidation.ok("Issued comment to issue: " + issue.getHtmlUrl()); } catch (Exception ex) { return FormValidation.error("Unable to issue comment: " + ex); } }
public static void logOpen(List<GHIssue> issues) { for (GHIssue issue : issues) { LOG.info("Open issue " + issue.getHtmlUrl()); } }
public static void addConflictsComment(GHIssue issue, List<DependencyVersionChange> pendingChanges, String operationDescription, DependenciesCheck check) throws IOException { String prefix = PENDING_CHANGE_COMMENT_PREFIX + operationDescription + "\n"; String issueComment = prefix + conflictChangesComment(pendingChanges, check); issue.comment(issueComment); }
private String getApiRoute() { return "/repos/"+owner.getRepository().getOwnerName()+"/"+owner.getRepository().getName()+"/issues/comments/" + id; } }
/** * Lets try find the issue */ public static GHIssue findIssue(CommandContext context, List<GHIssue> issues) { String prefix = context.createIssueTitlePrefix(); if (issues != null) { for (GHIssue issue : issues) { String title = issue.getTitle(); if (title != null && title.startsWith(prefix)) { return issue; } } } return null; }
/** * Checks for skip build phrase in pull request title and body. If present it updates shouldRun as false. * * @param issue The GitHub issue * @return the skip phrase or null if should not skip */ public String checkSkipBuildPhrase(GHIssue issue) { Set<String> skipBuildPhrases = getSkipBuildPhrases(); skipBuildPhrases.remove(""); Map<Pattern, String> skipPatterns = new HashMap<Pattern, String>(); for (String skipBuildPhrase : skipBuildPhrases) { skipBuildPhrase = skipBuildPhrase.trim(); skipPatterns.put(compilePattern(skipBuildPhrase), skipBuildPhrase); } // check in title String pullRequestTitle = issue.getTitle(); String skipBuildPhrase = checkSkipBuildInString(skipPatterns, pullRequestTitle); if (StringUtils.isNotBlank(skipBuildPhrase)) { return skipBuildPhrase; } // not found in title, check in body String pullRequestBody = issue.getBody(); skipBuildPhrase = checkSkipBuildInString(skipPatterns, pullRequestBody); if (StringUtils.isNotBlank(skipBuildPhrase)) { return skipBuildPhrase; } return null; }
public static List<GHIssue> getOpenIssues(GHRepository ghRepository, String label) throws IOException { List<GHIssue> issues = retryGithub(() -> ghRepository.getIssues(GHIssueState.OPEN)); List<GHIssue> answer = new ArrayList<>(); for (GHIssue issue : issues) { if (GitHubHelpers.hasLabel(getLabels(issue), label) && !issue.isPullRequest()) { answer.add(issue); } } return answer; }
public static void closeIssues(List<GHIssue> issues) throws IOException { for (GHIssue issue : issues) { issue.close(); } }
private void _addLabels(Collection<String> names) throws IOException { List<String> newLabels = new ArrayList<String>(); for (GHLabel label : getLabels()) { newLabels.add(label.getName()); } for (String name : names) { if (!newLabels.contains(name)) { newLabels.add(name); } } setLabels(newLabels.toArray(new String[0])); }