Prevent post-processing of patches that does not affect any component
Change-Id: If3d57536f04ddf58188e79e69dea819b1bb008cc
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
diff --git a/src/main/java/io/fd/maintainer/plugin/events/OnPatchsetVerifiedListener.java b/src/main/java/io/fd/maintainer/plugin/events/OnPatchsetVerifiedListener.java
index b430e43..194d626 100644
--- a/src/main/java/io/fd/maintainer/plugin/events/OnPatchsetVerifiedListener.java
+++ b/src/main/java/io/fd/maintainer/plugin/events/OnPatchsetVerifiedListener.java
@@ -17,6 +17,7 @@
package io.fd.maintainer.plugin.events;
import static io.fd.maintainer.plugin.service.PatchsetReviewInfo.ReviewState.ALL_COMPONENTS_REVIEWED;
+import static io.fd.maintainer.plugin.service.PatchsetReviewInfo.ReviewState.COMMITTER_ATTENTION_NEEDED;
import static java.lang.String.format;
import com.google.gerrit.reviewdb.client.Account;
@@ -152,7 +153,11 @@
} else {
LOG.warn("Auto submit turned off");
}
- } else {
+ } else if (patchsetReviewInfo.getReviewState() == COMMITTER_ATTENTION_NEEDED) {
+ LOG.info("Patchset {} affects no configured components, committers attention needed",
+ currentPatchset.getId());
+ }
+ else {
LOG.info(
"Patchset {} does not have verifications from following components yet : {}",
currentPatchset.getId(), patchsetReviewInfo.getMissingComponentReview());
diff --git a/src/main/java/io/fd/maintainer/plugin/service/PatchsetReviewInfo.java b/src/main/java/io/fd/maintainer/plugin/service/PatchsetReviewInfo.java
index ff3e08c..f43522f 100644
--- a/src/main/java/io/fd/maintainer/plugin/service/PatchsetReviewInfo.java
+++ b/src/main/java/io/fd/maintainer/plugin/service/PatchsetReviewInfo.java
@@ -16,6 +16,8 @@
package io.fd.maintainer.plugin.service;
+import static io.fd.maintainer.plugin.service.PatchsetReviewInfo.ReviewState.COMMITTER_ATTENTION_NEEDED;
+
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.patch.PatchList;
import io.fd.maintainer.plugin.parser.ComponentPath;
@@ -51,6 +53,14 @@
.map(index::getComponentForPath)
.filter(index::isReviewComponent)
.collect(Collectors.toSet());
+
+ // no components detected, do nothing
+ if (componentsForPatchlist.isEmpty()) {
+ reviewState = COMMITTER_ATTENTION_NEEDED;
+ missingComponentReview = Collections.emptySet();
+ return;
+ }
+
final Set<String> componentsCurrentlyReviewed = currentVerificationAuthors.stream()
.map(account -> index.getComponentsForMaintainer(account.getFullName()))
.flatMap(Collection::stream)
@@ -77,6 +87,7 @@
public enum ReviewState {
ALL_COMPONENTS_REVIEWED,
- MISSING_COMPONENT_REVIEW;
+ MISSING_COMPONENT_REVIEW,
+ COMMITTER_ATTENTION_NEEDED;// case when patchset does not contain any files under specified components
}
}