[Bug fix] fix check on comment prefix
The patchet set number is written before the prefix.
diff --git a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
index c798186..1b5f1c1 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
@@ -110,8 +110,14 @@
}
private void onCommendAdded(final CommentAddedEvent newComment) {
- // Avoid infinite loop when this plugin comments the review
- if (config.getBotEmail().equals(newComment.author.email) && newComment.comment.startsWith(config.getCommentPrefix())) {
+ // Avoid infinite loop when this plugin comments the review.
+ //
+ // A plugin comment will typically look like:
+ // Patch Set 1:
+ //
+ // Cross-repo comment:
+ // ...
+ if (config.getBotEmail().equals(newComment.author.email) && newComment.comment.contains(config.getCommentPrefix())) {
return;
}
diff --git a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeConfig.java b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeConfig.java
index 4ea8869..3ff8c17 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeConfig.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeConfig.java
@@ -21,7 +21,7 @@
private final static String defaultBotEmail = "qabot@criteo.com";
private final static String defaultTopicPrefix = "crossrepo/";
public final static String TOPIC_PREFIX_KEY = "topicPrefix";
- private final static String defaultCommentPrefix = "[crossrepo]";
+ private final static String defaultCommentPrefix = "Cross-repo comment:" + System.lineSeparator();
public final static String COMMENT_PREFIX_KEY = "commitPrefix";
public static final String getDefaultBotEmail() {
diff --git a/src/main/java/com/criteo/gerrit/plugins/automerge/ReviewUpdater.java b/src/main/java/com/criteo/gerrit/plugins/automerge/ReviewUpdater.java
index 1ecdeb9..ef6a7a1 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/ReviewUpdater.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/ReviewUpdater.java
@@ -64,7 +64,7 @@
private ReviewInput createCrossrepoComment(final String commentTemplate) {
final ReviewInput message = new ReviewInput();
- message.message = config.getCommentPrefix() + " " + getCommentFromFile(commentTemplate);
+ message.message = config.getCommentPrefix() + getCommentFromFile(commentTemplate);
return message;
}
}