本文整理汇总了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);
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}