Remove waiting for triage label when Bot closes an issue
This commit is contained in:
@@ -30,6 +30,17 @@ public interface IssueListener {
|
||||
*
|
||||
* @param issue the open issue
|
||||
*/
|
||||
void onOpenIssue(Issue issue);
|
||||
default void onOpenIssue(Issue issue) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Notification that the given {@code issue} is being closed.
|
||||
*
|
||||
* @param issue the open issue
|
||||
*/
|
||||
default void onIssueClosure(Issue issue) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,11 +16,14 @@
|
||||
|
||||
package io.spring.issuebot.feedback;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import io.spring.issuebot.GitHubProperties;
|
||||
import io.spring.issuebot.IssueListener;
|
||||
import io.spring.issuebot.github.GitHubOperations;
|
||||
|
||||
/**
|
||||
@@ -35,7 +38,8 @@ class FeedbackConfiguration {
|
||||
|
||||
@Bean
|
||||
FeedbackIssueListener feedbackIssueListener(GitHubOperations gitHub,
|
||||
GitHubProperties githubProperties, FeedbackProperties feedbackProperties) {
|
||||
GitHubProperties githubProperties, FeedbackProperties feedbackProperties,
|
||||
List<IssueListener> issueListener) {
|
||||
return new FeedbackIssueListener(gitHub, feedbackProperties.getRequiredLabel(),
|
||||
githubProperties.getRepository().getCollaborators(),
|
||||
githubProperties.getCredentials().getUsername(),
|
||||
@@ -44,7 +48,7 @@ class FeedbackConfiguration {
|
||||
feedbackProperties.getRequiredLabel(),
|
||||
feedbackProperties.getReminderLabel(),
|
||||
feedbackProperties.getReminderComment(),
|
||||
feedbackProperties.getCloseComment()));
|
||||
feedbackProperties.getCloseComment(), issueListener));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
package io.spring.issuebot.feedback;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import io.spring.issuebot.IssueListener;
|
||||
import io.spring.issuebot.github.GitHubOperations;
|
||||
import io.spring.issuebot.github.Issue;
|
||||
import io.spring.issuebot.github.Label;
|
||||
@@ -41,15 +43,18 @@ final class StandardFeedbackListener implements FeedbackListener {
|
||||
|
||||
private final String closeComment;
|
||||
|
||||
private final List<IssueListener> issueListeners;
|
||||
|
||||
StandardFeedbackListener(GitHubOperations gitHub, String providedLabel,
|
||||
String requiredLabel, String reminderLabel, String reminderComment,
|
||||
String closeComment) {
|
||||
String closeComment, List<IssueListener> issueListeners) {
|
||||
this.gitHub = gitHub;
|
||||
this.providedLabel = providedLabel;
|
||||
this.requiredLabel = requiredLabel;
|
||||
this.reminderLabel = reminderLabel;
|
||||
this.reminderComment = reminderComment;
|
||||
this.closeComment = closeComment;
|
||||
this.issueListeners = issueListeners;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,6 +82,7 @@ final class StandardFeedbackListener implements FeedbackListener {
|
||||
this.gitHub.close(issue);
|
||||
this.gitHub.removeLabel(issue, this.requiredLabel);
|
||||
this.gitHub.removeLabel(issue, this.reminderLabel);
|
||||
this.issueListeners.forEach((listener) -> listener.onIssueClosure(issue));
|
||||
}
|
||||
|
||||
private boolean hasReminderLabel(Issue issue) {
|
||||
|
||||
@@ -48,4 +48,9 @@ final class LabelApplyingTriageListener implements TriageListener {
|
||||
this.gitHub.addLabel(issue, this.label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doesNotRequireTriage(Issue issue) {
|
||||
this.gitHub.removeLabel(issue, this.label);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -45,11 +45,6 @@ final class TriageIssueListener implements IssueListener {
|
||||
this.triageListener = triageListener;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see io.spring.issuebot.IssueListener#onOpenIssue(io.spring.issuebot.github.Issue)
|
||||
*/
|
||||
@Override
|
||||
public void onOpenIssue(Issue issue) {
|
||||
if (requiresTriage(issue)) {
|
||||
@@ -66,4 +61,9 @@ final class TriageIssueListener implements IssueListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIssueClosure(Issue issue) {
|
||||
this.triageListener.doesNotRequireTriage(issue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ package io.spring.issuebot.triage;
|
||||
import io.spring.issuebot.github.Issue;
|
||||
|
||||
/**
|
||||
* A {@code TriageListener} is notified of issues that require triage.
|
||||
* A {@code TriageListener} is notified of issues' triage requirements.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@@ -31,4 +31,12 @@ interface TriageListener {
|
||||
* @param issue the issue
|
||||
*/
|
||||
void requiresTriage(Issue issue);
|
||||
|
||||
/**
|
||||
* Notification that the given {@code issue} does not require triage.
|
||||
*
|
||||
* @param issue the issue
|
||||
*/
|
||||
void doesNotRequireTriage(Issue issue);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,9 +18,11 @@ package io.spring.issuebot.feedback;
|
||||
|
||||
import java.time.OffsetDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import io.spring.issuebot.IssueListener;
|
||||
import io.spring.issuebot.github.GitHubOperations;
|
||||
import io.spring.issuebot.github.Issue;
|
||||
import io.spring.issuebot.github.Label;
|
||||
@@ -38,9 +40,12 @@ public class StandardFeedbackListenerTests {
|
||||
|
||||
private final GitHubOperations gitHub = mock(GitHubOperations.class);
|
||||
|
||||
private final IssueListener issueListener = mock(IssueListener.class);
|
||||
|
||||
private final FeedbackListener listener = new StandardFeedbackListener(this.gitHub,
|
||||
"feedback-provided", "feedback-required", "feedback-reminder",
|
||||
"Please provide requested feedback", "Closing due to lack of feedback");
|
||||
"Please provide requested feedback", "Closing due to lack of feedback",
|
||||
Arrays.asList(this.issueListener));
|
||||
|
||||
private final Issue issue = new Issue(null, null, null, null, null, new ArrayList<>(),
|
||||
null, null);
|
||||
@@ -88,6 +93,7 @@ public class StandardFeedbackListenerTests {
|
||||
verify(this.gitHub).addComment(this.issue, "Closing due to lack of feedback");
|
||||
verify(this.gitHub).close(this.issue);
|
||||
verify(this.gitHub).removeLabel(this.issue, "feedback-required");
|
||||
verify(this.issueListener).onIssueClosure(this.issue);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user