commit 4235a11a68e1d69171298aaa48015317aeddb869 Author: Gal Paikin Date: Thu Oct 1 10:48:25 2020 +0300 Remove logic that adds owner and uploader because of robot comments We found that it creates too much noise to add the attention set for that reason. If a bot wants the owner to take attention, the bot should vote negatively. Currently, this is the only way for robots to trigger the attention set (unless they manually call the attention set endpoint or name reviewers specifically in the ReviewInput object). Change-Id: I9009f06461c6ba488fd36d0e64b77d9d36a821eb diff --git a/java/com/google/gerrit/server/restapi/change/ReplyAttentionSetUpdates.java b/java/com/google/gerrit/server/restapi/change/ReplyAttentionSetUpdates.java index c523036..65c0cda 100644 --- a/java/com/google/gerrit/server/restapi/change/ReplyAttentionSetUpdates.java +++ b/java/com/google/gerrit/server/restapi/change/ReplyAttentionSetUpdates.java @@ -125,7 +125,6 @@ public class ReplyAttentionSetUpdates { } if (serviceUserClassifier.isServiceUser(currentUser.getAccountId())) { botsWithNegativeLabelsAddOwnerAndUploader(bu, changeNotes, input); - robotCommentAddsOwnerAndUploader(bu, changeNotes, input); return; } @@ -254,8 +253,8 @@ public class ReplyAttentionSetUpdates { } /** - * Bots don't process automatic rules, but they do have special rules; One of them: If voted - * negatively on a label, add the owner and uploader. + * Bots don't process automatic rules, the only attention set change they do is this rule: Add + * owner and uploader when a bot votes negatively. */ private void botsWithNegativeLabelsAddOwnerAndUploader( BatchUpdate bu, ChangeNotes changeNotes, ReviewInput input) { @@ -270,22 +269,6 @@ public class ReplyAttentionSetUpdates { } /** - * Bots don't process automatic rules, but they do have special rules; One of them: When adding a - * robot comment, add the owner and uploader. This only applies on open changes. - */ - private void robotCommentAddsOwnerAndUploader( - BatchUpdate bu, ChangeNotes changeNotes, ReviewInput input) { - if (input.robotComments != null && changeNotes.getChange().isNew()) { - Account.Id uploader = changeNotes.getCurrentPatchSet().uploader(); - Account.Id owner = changeNotes.getChange().getOwner(); - addToAttentionSet(bu, changeNotes, owner, "A robot comment was added", false); - if (!owner.equals(uploader)) { - addToAttentionSet(bu, changeNotes, uploader, "A robot comment was added", false); - } - } - } - - /** * Adds the user to the attention set * * @param bu BatchUpdate to perform the updates to the attention set diff --git a/javatests/com/google/gerrit/acceptance/rest/change/AttentionSetIT.java b/javatests/com/google/gerrit/acceptance/rest/change/AttentionSetIT.java index cc6b199..976be96 100644 --- a/javatests/com/google/gerrit/acceptance/rest/change/AttentionSetIT.java +++ b/javatests/com/google/gerrit/acceptance/rest/change/AttentionSetIT.java @@ -1279,25 +1279,6 @@ public class AttentionSetIT extends AbstractDaemonTest { } @Test - public void robotCommentAddsOwnerOnNewChanges() throws Exception { - TestAccount robot = - accountCreator.create("robot2", "robot2@example.com", "Ro Bot", "Ro", "Service Users"); - PushOneCommit.Result r = createChange(); - requestScopeOperations.setApiUser(robot.id()); - ReviewInput reviewInput = new ReviewInput(); - ReviewInput.RobotCommentInput robotCommentInput = - TestCommentHelper.createRobotCommentInputWithMandatoryFields("a.txt"); - reviewInput.robotComments = ImmutableMap.of("a.txt", ImmutableList.of(robotCommentInput)); - change(r).current().review(reviewInput); - - AttentionSetUpdate attentionSet = - Iterables.getOnlyElement(getAttentionSetUpdatesForUser(r, admin)); - assertThat(attentionSet).hasAccountIdThat().isEqualTo(admin.id()); - assertThat(attentionSet).hasOperationThat().isEqualTo(AttentionSetUpdate.Operation.ADD); - assertThat(attentionSet).hasReasonThat().isEqualTo("A robot comment was added"); - } - - @Test public void robotCommentDoesNotAddOwnerOnClosedChanges() throws Exception { TestAccount robot = accountCreator.create("robot2", "robot2@example.com", "Ro Bot", "Ro", "Service Users");