Drop "Patch Set: <num>" prefix from change message that lists owned paths
This prefix triggers special logic in the web frontend. If this prefix
is present the frontend parses approvals from the message and shows
approval chips for them. Due to this it looks like approvals have been
applied twice. If a code-owners approval is applied and the message to
inform about the owned paths is posted asynchronously there are 2 change
messages and the web frontend shows an approval chip for both of them:
1. "Patch Set X: Code-Owner+1" posted by Gerrit core
2. "Patch Set X: By voting Code-Review+1 the following files are now
code-owner approved by YYY: ..." posted by the code-owners plugin
By dropping the "Patch Set: <num>" prefix from the second change
message, the approval chip will only be shown for the first message.
Dropping the patch set information from the second change message is
fine, since the patch set to which the message relates is still
available from the change message meta data.
This problem started happening after the code-owners plugin has been
changed to post the code-owner approved paths asynchronously in a
separate change message, rather then extending the change message that
Gerrit core posts about the approval (see change I129e611af).
Bug: Google b/276276203
Signed-off-by: Edwin Kempin <firstname.lastname@example.org>
diff --git a/java/com/google/gerrit/plugins/codeowners/backend/OnCodeOwnerApproval.java b/java/com/google/gerrit/plugins/codeowners/backend/OnCodeOwnerApproval.java
index 3977521..b3417dc 100644
@@ -509,10 +509,7 @@
- String.format("Patch Set %s: %s", patchSet.id().get(), message.get()),
+ changeMessageUtil.setChangeMessage(ctx, message.get(), TAG_ADD_CODE_OWNER_APPROVAL);
diff --git a/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/OnCodeOwnerApprovalIT.java b/javatests/com/google/gerrit/plugins/codeowners/acceptance/api/OnCodeOwnerApprovalIT.java
index 3875eb9..ea3b6ae 100644
@@ -1183,8 +1183,7 @@
- "Patch Set 1: "
- + "By voting Code-Review+1 the following files are now code-owner approved by"
+ "By voting Code-Review+1 the following files are now code-owner approved by"
+ " %s:\n"
+ "* %s\n",