当前位置: 首页>>代码示例>>Java>>正文


Java GHLabel类代码示例

本文整理汇总了Java中org.kohsuke.github.GHLabel的典型用法代码示例。如果您正苦于以下问题:Java GHLabel类的具体用法?Java GHLabel怎么用?Java GHLabel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GHLabel类属于org.kohsuke.github包,在下文中一共展示了GHLabel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: perform

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:25,代码来源:GitHubPRLabelAddPublisher.java

示例2: perform

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:25,代码来源:GitHubPRLabelRemovePublisher.java

示例3: check

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
@Override
public GitHubPRCause check(GitHubPRTrigger gitHubPRTrigger, GHPullRequest remotePR,
                           @CheckForNull GitHubPRPullRequest localPR, TaskListener listener) throws IOException {
    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<String>();

    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 = new GitHubPRCause(remotePR, label.getLabelsSet() + " labels exist", isSkip());
    }

    return cause;
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:25,代码来源:GitHubPRLabelExistsEvent.java

示例4: check

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
@Override
public GitHubPRCause check(GitHubPRTrigger gitHubPRTrigger, GHPullRequest remotePR,
                           @CheckForNull GitHubPRPullRequest localPR, TaskListener listener) throws IOException {
    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 new GitHubPRCause(remotePR, "PR has label: " + labelPatternStr, isSkip());
            }
        }
    }

    return null;
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:19,代码来源:GitHubPRLabelPatternExistsEvent.java

示例5: twoOfThreeLabelsWasRemoved

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
/**
 * Case when there is three checked labels and there is one that wasn't removed yet.
 */
@Test
public void twoOfThreeLabelsWasRemoved() throws IOException {
    Set<String> localLabels = new HashSet<>();
    localLabels.add(TESTS_FAILURE);

    List<GHLabel> remoteLabels = new ArrayList<GHLabel>();
    remoteLabels.add(label);

    commonExpectations(localLabels);
    when(issue.getLabels()).thenReturn(remoteLabels);
    when(label.getName()).thenReturn(TESTS_FAILURE);

    GitHubPRLabelRemovedEvent instance = new GitHubPRLabelRemovedEvent(labels);
    GitHubPRCause cause = instance.check(null, remotePr, localPR, listener);
    Assert.assertNull(cause);
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:20,代码来源:GitHubPRLabelRemovedEventTest.java

示例6: noLabelsWasRemoved

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
/**
 * Case when there is three checked labels and no one of them was removed.
 */
@Test
public void noLabelsWasRemoved() throws IOException {
    Set<String> localLabels = new HashSet<>();
    localLabels.add(NOT_READY_FOR_MERGE);
    localLabels.add(NOT_REVIEWED);
    localLabels.add(TESTS_FAILURE);

    List<GHLabel> remoteLabels = new ArrayList<GHLabel>();
    for (int i = 0; i < localLabels.size(); i++) {
        remoteLabels.add(label);
    }

    commonExpectations(localLabels);
    when(issue.getLabels()).thenReturn(remoteLabels);
    when(label.getName()).thenReturn(TESTS_FAILURE);
    when(label.getName()).thenReturn(NOT_READY_FOR_MERGE);
    when(label.getName()).thenReturn(NOT_REVIEWED);

    GitHubPRLabelRemovedEvent instance = new GitHubPRLabelRemovedEvent(labels);
    GitHubPRCause cause = instance.check(null, remotePr, localPR, listener);
    Assert.assertNull(cause);
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:26,代码来源:GitHubPRLabelRemovedEventTest.java

示例7: secondOfThreeLabelsWasAdded

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
/**
 * Case when there is three checked labels and there is one that was added and one that already exists.
 */
@Test
public void secondOfThreeLabelsWasAdded() throws IOException {
    Set<String> localLabels = new HashSet<>(Collections.singleton(LOCALLY_TESTED));

    List<GHLabel> remoteLabels = asList(testLabel, reviewedLabel);

    commonExpectations(localLabels);
    
    when(issue.getLabels()).thenReturn(remoteLabels);
    when(testLabel.getName()).thenReturn(LOCALLY_TESTED);
    when(reviewedLabel.getName()).thenReturn(REVIEWED);

    GitHubPRCause cause = new GitHubPRLabelAddedEvent(labels).check(null, remotePr, localPR, listener);
    assertNull(cause);
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:19,代码来源:GitHubPRLabelAddedEventTest.java

示例8: thirdOfThreeLabelsWasAdded

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
/**
 * Case when there is three checked labels and all of them was already added.
 */
@Test
@Ignore
public void thirdOfThreeLabelsWasAdded() throws IOException {
    Set<String> localLabels = new HashSet<>(asList(LOCALLY_TESTED, MERGE));

    List<GHLabel> remoteLabels = asList(testLabel, reviewedLabel, mergeLabel);

    commonExpectations(localLabels);

    when(issue.getLabels()).thenReturn(remoteLabels);
    when(testLabel.getName()).thenReturn(LOCALLY_TESTED);
    when(reviewedLabel.getName()).thenReturn(REVIEWED);
    when(mergeLabel.getName()).thenReturn(MERGE);

    causeCreationExpectations();

    GitHubPRCause cause = new GitHubPRLabelAddedEvent(labels).check(null, remotePr, localPR, listener);
    assertThat(cause.getLabels(), equalTo(localLabels));
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:23,代码来源:GitHubPRLabelAddedEventTest.java

示例9: allLabelsAlreadyExist

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
/**
 * Case when there is three checked labels and all of them was already added.
 */
@Test
public void allLabelsAlreadyExist() throws IOException {
    Set<String> localLabels = new HashSet<>(asList(LOCALLY_TESTED, MERGE, REVIEWED));
    List<GHLabel> remoteLabels = asList(testLabel, reviewedLabel, mergeLabel);

    commonExpectations(localLabels);

    when(issue.getLabels()).thenReturn(remoteLabels);
    when(testLabel.getName()).thenReturn(LOCALLY_TESTED);
    when(reviewedLabel.getName()).thenReturn(REVIEWED);
    when(mergeLabel.getName()).thenReturn(MERGE);

    GitHubPRLabelAddedEvent instance = new GitHubPRLabelAddedEvent(labels);
    GitHubPRCause cause = instance.check(null, remotePr, localPR, listener);
    assertNull(cause);
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:20,代码来源:GitHubPRLabelAddedEventTest.java

示例10: noLabelsWasRemoved

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
/**
 * Case when there is three checked labels and no one of them was removed.
 */
@Test
public void noLabelsWasRemoved() throws IOException {
    Set<String> localLabels = new HashSet<>(asList(MERGE, REVIEWED, LOCALLY_TESTED));
    List<GHLabel> remoteLabels = asList(testLabel, reviewedLabel, mergeLabel);

    commonExpectations(localLabels);
    
    when(issue.getLabels()).thenReturn(remoteLabels);
    when(testLabel.getName()).thenReturn(LOCALLY_TESTED);
    when(reviewedLabel.getName()).thenReturn(REVIEWED);
    when(mergeLabel.getName()).thenReturn(MERGE);

    GitHubPRCause cause = new GitHubPRLabelAddedEvent(labels).check(null, remotePr, localPR, listener);
    assertNull(cause);
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:19,代码来源:GitHubPRLabelAddedEventTest.java

示例11: hasLabel

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
public static boolean hasLabel(Collection<GHLabel> labels, String label) {
    if (labels != null) {
        for (GHLabel ghLabel : labels) {
            if (Objects.equal(label, ghLabel.getName())) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:11,代码来源:GitHubHelpers.java

示例12: isSlackIssue

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
public static boolean isSlackIssue(GHIssue issue) throws IOException {
	for (GHLabel label : issue.getLabels()) {
		for (String slackLabel : getSlackLabels()) {
			if (label.getName().equalsIgnoreCase(slackLabel)) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:eraether,项目名称:WatchWordBot,代码行数:11,代码来源:GitHubHelper.java

示例13: check

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
@Override
public GitHubPRCause check(GitHubPRTrigger gitHubPRTrigger, GHPullRequest remotePR,
                           @CheckForNull GitHubPRPullRequest localPR, TaskListener listener) throws IOException {
    if (remotePR.getState().equals(GHIssueState.CLOSED)) {
        return null; // already closed, skip check?
    }

    if (label == null) {
        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 = new GitHubPRCause(remotePR, label.getLabelsSet() + " labels were added", false);
    }

    return cause;
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:35,代码来源:GitHubPRLabelAddedEvent.java

示例14: check

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
@Override
public GitHubPRCause check(GitHubPRTrigger gitHubPRTrigger, GHPullRequest remotePR,
                           @CheckForNull GitHubPRPullRequest localPR, TaskListener listener) throws IOException {
    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 = new GitHubPRCause(remotePR, label.getLabelsSet() + " labels not exist", isSkip());
    }

    return cause;
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:28,代码来源:GitHubPRLabelNotExistsEvent.java

示例15: before

import org.kohsuke.github.GHLabel; //导入依赖的package包/类
@Before
public void before() throws IOException {
    when(remotePr.getUser()).thenReturn(ghUser);
    when(remotePr.getHead()).thenReturn(ghCommitPointer);
    when(remotePr.getBase()).thenReturn(ghCommitPointer);
    when(ghCommitPointer.getSha()).thenReturn("1r134rsha324");
    when(ghCommitPointer.getRef()).thenReturn("some/branch");
    when(remotePr.getRepository()).thenReturn(ghRepository);
    when(ghRepository.getIssue(0)).thenReturn(ghIssue);
    when(ghIssue.getLabels()).thenReturn(Collections.<GHLabel>emptySet());
    when(remotePr.getState()).thenReturn(GHIssueState.OPEN);
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:13,代码来源:GitHubPRNonMergeableEventTest.java


注:本文中的org.kohsuke.github.GHLabel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。