summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Milanesio <luca.milanesio@gmail.com>2022-05-23 17:25:23 +0100
committerLuca Milanesio <luca.milanesio@gmail.com>2022-05-23 18:28:32 +0000
commit2b42c87a541b20a6c3ee01da7265e86c6ee6144c (patch)
tree352c2ce6a3b0d0e669fba13206f5121042988bd7
parent2849b7a1806ea8a66538a6ccac88d20a50feddb2 (diff)
Do not try to copy labels with value == 0
When calculating the inferred approvals for the copied labels, the ones with value == 0 would never be stored and therefore should not be selected. Selecting an approval with a value == 0 causes the change to receive a series of empty change notes which would cause unneeded noise and create redundant Git objects and commits. Release-Notes: skip Change-Id: I660e350f6f08fc75803f3e34cb00a391f19c3d88
-rw-r--r--java/com/google/gerrit/server/approval/ApprovalsUtil.java12
1 files changed, 7 insertions, 5 deletions
diff --git a/java/com/google/gerrit/server/approval/ApprovalsUtil.java b/java/com/google/gerrit/server/approval/ApprovalsUtil.java
index 08ea6bc0fb..77ac2e2390 100644
--- a/java/com/google/gerrit/server/approval/ApprovalsUtil.java
+++ b/java/com/google/gerrit/server/approval/ApprovalsUtil.java
@@ -383,13 +383,15 @@ public class ApprovalsUtil {
}
for (PatchSetApproval psa : inferred) {
- if (approvalTable.contains(psa.labelId(), psa.accountId())) {
- Short v = approvalTable.get(psa.labelId(), psa.accountId());
- if (v.shortValue() != psa.value()) {
+ if (psa.value() != 0) {
+ if (approvalTable.contains(psa.labelId(), psa.accountId())) {
+ Short v = approvalTable.get(psa.labelId(), psa.accountId());
+ if (v.shortValue() != psa.value()) {
+ changeUpdate.putCopiedApproval(psa);
+ }
+ } else {
changeUpdate.putCopiedApproval(psa);
}
- } else {
- changeUpdate.putCopiedApproval(psa);
}
}
}