Push comment when non merged commit blocks a cross-repo
Change-Id: I2a0235e73b4a5c21b010bf446ded7b842489f4d0
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 dbf0776..0419213 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
@@ -226,10 +226,8 @@
if (!info.mergeable || dependsOnNonMergedCommit) {
log.info("Change {} is not mergeable because same topic change {} {}", change.number, info._number,
!info.mergeable ? "is non mergeable" : "depends on a non merged commit.");
- if (!info.mergeable) {
- reviewUpdater.commentOnReview(change.project, change.number,
- String.format(config.cantMergeGitConflict.getContent(), info._number));
- }
+ PluginComment comment = !info.mergeable ? config.cantMergeGitConflict : config.cantMergeDependsOnNonMerged;
+ reviewUpdater.commentOnReview(change.project, change.number, String.format(comment.getContent(), info._number));
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 55fa745..cd048c6 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeConfig.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomergeConfig.java
@@ -18,6 +18,7 @@
public final PluginComment atomicReviewDetected;
public final PluginComment atomicReviewsSameRepo;
public final PluginComment cantMergeGitConflict;
+ public final PluginComment cantMergeDependsOnNonMerged;
private final static String defaultBotEmail = "qabot@criteo.com";
private final static String defaultTopicPrefix = "crossrepo/";
@@ -55,6 +56,8 @@
"This cross-repo review depends on a not merged commit that must be merged first.");
cantMergeGitConflict = new PluginComment(getCommentPath("cantmerge_git_conflict.txt"),
"This cross-repo review is blocked by a git conflict on change #/c/%d.");
+ cantMergeDependsOnNonMerged = new PluginComment(getCommentPath("cantmerge_depends_on_non_merged.txt"),
+ "This cross-repo review is blocked by a non merged commit below #/c/%d.");
}
public final String getBotEmail() {
diff --git a/test.rb b/test.rb
index 1acfe59..3b0782e 100755
--- a/test.rb
+++ b/test.rb
@@ -86,6 +86,7 @@
approve_review(commit2)
+ check_last_message_contains(commit2, "blocked by a non merged commit below")
check_status(commit1a, 'NEW')
check_status(commit1b, 'NEW')
check_status(commit2, 'NEW')