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 _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 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); } }