@Override public Collection<GHLabel> getLabels() throws IOException { fetchIssue(); return super.getLabels(); }
@Override public Collection<GHLabel> getLabels() throws IOException { fetchIssue(); return super.getLabels(); }
/** * Lets return the labels on an issue with retries */ public static Collection<GHLabel> getLabels(GHIssue issue) throws IOException { return retryGithub(() -> issue.getLabels()); }
@Override public Collection<GHLabel> getLabels() throws IOException { fetchIssue(); return super.getLabels(); }
/** * Lets return the labels on an issue with retries */ public static Collection<GHLabel> getLabels(GHIssue issue) throws IOException { return retryGithub(() -> issue.getLabels()); }
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])); }
/** * Returns issue label for release notes. * @param issue issue. * @return issue label for release notes * @throws IOException if an I/o error occurs. */ private static String getIssueLabelFrom(GHIssue issue) throws IOException { final Collection<GHLabel> issueLabels = issue.getLabels(); final Optional<GHLabel> label = issueLabels.stream() .filter(input -> Arrays.binarySearch(Constants.ISSUE_LABELS, input.getName()) >= 0) .findFirst(); return label.map(GHLabel::getName).orElse(""); } }
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])); }
private void _removeLabels(Collection<String> names) throws IOException { List<String> newLabels = new ArrayList<String>(); for (GHLabel l : getLabels()) { if (!names.contains(l.getName())) { newLabels.add(l.getName()); } } setLabels(newLabels.toArray(new String[0])); }
private void _removeLabels(Collection<String> names) throws IOException { List<String> newLabels = new ArrayList<String>(); for (GHLabel l : getLabels()) { if (!names.contains(l.getName())) { newLabels.add(l.getName()); } } setLabels(newLabels.toArray(new String[0])); }
@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; } try { HashSet<String> remoteLabels = new HashSet<>(); final GHIssue ghIssue = getGhIssue(run); //remote labels List -> Set ghIssue.getLabels().stream() .map(GHLabel::getName) .collect(Collectors.toList()) .forEach(remoteLabels::add); remoteLabels.addAll(getLabelProperty().getLabelsSet()); ghIssue.setLabels(remoteLabels.toArray(new String[remoteLabels.size()])); } catch (IOException ex) { final int number = getPRNumberFromPRCause(run); listener.getLogger().println("Couldn't add label for PR #" + number + ex.getMessage()); LOGGER.error("Couldn't add label for PR #{}", number, ex); handlePublisherError(run); } }
@Override public GitHubPRCause check(@Nonnull GitHubPRDecisionContext prDecisionContext) throws IOException { TaskListener listener = prDecisionContext.getListener(); GHPullRequest remotePR = prDecisionContext.getRemotePR(); final PrintStream logger = listener.getLogger(); for (GHLabel ghLabel : remotePR.getRepository().getIssue(remotePR.getNumber()).getLabels()) { for (String labelPatternStr : label.getLabelsSet()) { Pattern labelPattern = Pattern.compile(labelPatternStr); if (labelPattern.matcher(ghLabel.getName()).matches()) { logger.println(DISPLAY_NAME + ": Pull request has label: " + labelPatternStr); LOGGER.info("Pull request has '{}' label.", labelPatternStr); return prDecisionContext.newCause("PR has label: " + labelPatternStr, isSkip()); } } } return null; }
@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; } final int number = getPRNumberFromPRCause(run); try { HashSet<String> remoteLabels = getGhIssue(run).getLabels().stream() .map(GHLabel::getName) .collect(Collectors.toCollection(HashSet::new)); //remote labels List -> Set remoteLabels.removeAll(getLabelProperty().getLabelsSet()); // TODO print only really removing listener.getLogger().println("Removing labels: " + getLabelProperty().getLabelsSet()); getGhIssue(run).setLabels(remoteLabels.toArray(new String[remoteLabels.size()])); } catch (IOException ex) { listener.getLogger().println("Couldn't remove label for PR #" + number + ex); LOGGER.error("Couldn't remove label for PR #{}", number, ex); handlePublisherError(run); } }
@Override public GitHubPRCause check(@Nonnull GitHubPRDecisionContext prDecisionContext) throws IOException { TaskListener listener = prDecisionContext.getListener(); GHPullRequest remotePR = prDecisionContext.getRemotePR(); if (remotePR.getState().equals(GHIssueState.CLOSED)) { return null; // already closed, skip check? } GitHubPRCause cause = null; Collection<GHLabel> remoteLabels = remotePR.getRepository().getIssue(remotePR.getNumber()).getLabels(); Set<String> existingLabels = new HashSet<>(); for (GHLabel ghLabel : remoteLabels) { existingLabels.add(ghLabel.getName()); } if (existingLabels.containsAll(label.getLabelsSet())) { final PrintStream logger = listener.getLogger(); logger.println(DISPLAY_NAME + ": " + label.getLabelsSet() + " found"); cause = prDecisionContext.newCause(label.getLabelsSet() + " labels exist", isSkip()); } return cause; }
@Override public GitHubPRCause check(@Nonnull GitHubPRDecisionContext prDecisionContext) throws IOException { TaskListener listener = prDecisionContext.getListener(); GHPullRequest remotePR = prDecisionContext.getRemotePR(); if (remotePR.getState().equals(GHIssueState.CLOSED)) { return null; // already closed, skip check? } GitHubPRCause cause = null; Collection<GHLabel> remoteLabels = remotePR.getRepository().getIssue(remotePR.getNumber()).getLabels(); Set<String> existingLabels = new HashSet<>(); for (GHLabel ghLabel : remoteLabels) { existingLabels.add(ghLabel.getName()); } existingLabels.retainAll(label.getLabelsSet()); if (existingLabels.isEmpty()) { final PrintStream logger = listener.getLogger(); LOG.debug("{}:{} not found", DISPLAY_NAME, label.getLabelsSet()); logger.println(DISPLAY_NAME + ": " + label.getLabelsSet() + " not found"); cause = prDecisionContext.newCause(label.getLabelsSet() + " labels not exist", isSkip()); } return cause; }
@Override public GitHubPRCause check(@Nonnull GitHubPRDecisionContext prDecisionContext) throws IOException { TaskListener listener = prDecisionContext.getListener(); GitHubPRPullRequest localPR = prDecisionContext.getLocalPR(); GHPullRequest remotePR = prDecisionContext.getRemotePR(); if (remotePR.getState().equals(GHIssueState.CLOSED)) { return null; // already closed, skip check? } if (isNull(label)) { LOG.error("Label is null. Bad configured event: {}", getDescriptor().getDisplayName()); throw new IllegalStateException("Label is null. Bad configured event: " + getDescriptor().getDisplayName()); } //localPR exists before, checking for changes if (localPR != null && localPR.getLabels().containsAll(label.getLabelsSet())) { return null; // label existed before exiting } GitHubPRCause cause = null; Collection<GHLabel> labels = remotePR.getRepository().getIssue(remotePR.getNumber()).getLabels(); Set<String> existingLabels = new HashSet<String>(); for (GHLabel curLabel : labels) { existingLabels.add(curLabel.getName()); } if (existingLabels.containsAll(label.getLabelsSet())) { final PrintStream logger = listener.getLogger(); logger.println(DISPLAY_NAME + ": state has changed (" + label.getLabelsSet() + " labels were added"); cause = prDecisionContext.newCause(label.getLabelsSet() + " labels were added", false); } return cause; }
Collection<GHLabel> labels = remotePR.getRepository().getIssue(remotePR.getNumber()).getLabels(); for (GHLabel remoteLabel : labels) { for (String checkedLabel : label.getLabelsSet()) {
updateLabels(execute(() -> remoteRepo.getIssue(number).getLabels())); } catch (IOException e) { LOGGER.error("Can't retrieve label list: {}", e);