Try to autosubmit on new patch-sets
Do not wait for code-review comments or reviews and try to auto-submit
even when a new patch-set is created.
Change-Id: I34975f1df836b92308291845efc47256be17bb71
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 87a3092..fbed498 100644
--- a/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
+++ b/src/main/java/com/criteo/gerrit/plugins/automerge/AutomaticMerger.java
@@ -112,6 +112,12 @@
if (atomicityHelper.isAtomicReview(change)) {
processNewAtomicPatchSet(change);
}
+
+ try {
+ autoSubmitIfMergeable(change);
+ } catch (OrmException | RestApiException | IOException | UpdateException e) {
+ log.error("An exception occured while trying to merge change #" + change.number, e);
+ }
}
private void onCommentAdded(final CommentAddedEvent newComment) {
@@ -122,16 +128,21 @@
ChangeAttribute change = newComment.change.get();
try {
checkReviewExists(change.number);
- if (atomicityHelper.isSubmittable(change.project, change.number)) {
- log.info(String.format("Change %d is submittable. Will try to merge all related changes.", change.number));
- attemptToMerge(change);
- }
+ autoSubmitIfMergeable(change);
} catch (RestApiException | OrmException | UpdateException | IOException e) {
log.error("An exception occured while trying to atomic merge a change.", e);
throw new RuntimeException(e);
}
}
+ private void autoSubmitIfMergeable(ChangeAttribute change)
+ throws OrmException, RestApiException, NoSuchChangeException, IOException, UpdateException {
+ if (atomicityHelper.isSubmittable(change.project, change.number)) {
+ log.info(String.format("Change %d is submittable. Will try to merge all related changes.", change.number));
+ attemptToMerge(change);
+ }
+ }
+
/**
* Returns true if the plugin must handle this comment, i.e. if we are sure it does not come
* from this plugin (to avoid infinite loop).