From 85ce93deca395a3343588012ab8a3a6936ff935a Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 26 Jan 2009 12:53:18 -0800 Subject: [PATCH] Ensure any new reviewers for updated changes see it in their dashboard If a change is updated with a new patch set the caller may have given us additional reviewers to include on that change. Those should be added to the change just like if the change was new, so that those individuals can see the change in their dashboard. Signed-off-by: Shawn O. Pearce --- .../com/google/gerrit/server/ssh/Receive.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/appjar/src/main/java/com/google/gerrit/server/ssh/Receive.java b/appjar/src/main/java/com/google/gerrit/server/ssh/Receive.java index cbc2ea83e2..012191d825 100644 --- a/appjar/src/main/java/com/google/gerrit/server/ssh/Receive.java +++ b/appjar/src/main/java/com/google/gerrit/server/ssh/Receive.java @@ -635,8 +635,11 @@ class Receive extends AbstractGitCommand { boolean haveAuthor = false; boolean haveCommitter = false; - Set have = new HashSet(); + final Set haveApprovals = new HashSet(); + final Set myApprovals = + new HashSet(); for (ChangeApproval a : db.changeApprovals().byChange(change.getId())) { + haveApprovals.add(a.getAccountId()); if (!haveAuthor && authorId != null && a.getAccountId().equals(authorId)) { haveAuthor = true; @@ -649,23 +652,25 @@ class Receive extends AbstractGitCommand { if (me.equals(a.getAccountId())) { // Leave my own approvals alone. // - have.add(a.getCategoryId()); + myApprovals.add(a.getCategoryId()); } else if (a.getValue() > 0) { a.clear(); db.changeApprovals().update(Collections.singleton(a), txn); } } + final List allTypes = Common.getGerritConfig().getApprovalTypes(); for (final ApprovalType t : allTypes) { final ApprovalCategoryValue max = t.getMax(); final ApprovalCategory.Id catId = t.getCategory().getId(); - if (!have.contains(catId) && max != null) { + if (!myApprovals.contains(catId) && max != null) { // Insert any approval I haven't earlier recorded, using the // absolute maximum value, ignoring permissions. It truncates // at display time and when the issue is closed. // + haveApprovals.add(me); db.changeApprovals().insert( Collections.singleton(new ChangeApproval( new ChangeApproval.Key(change.getId(), me, catId), max @@ -675,18 +680,26 @@ class Receive extends AbstractGitCommand { if (allTypes.size() > 0) { final ApprovalCategory.Id catId = allTypes.get(allTypes.size() - 1).getCategory().getId(); - if (!haveAuthor && authorId != null && !me.equals(authorId)) { + if (authorId != null && haveApprovals.add(authorId)) { db.changeApprovals().insert( Collections.singleton(new ChangeApproval( new ChangeApproval.Key(change.getId(), authorId, catId), (short) 0)), txn); } - if (!haveCommitter && committerId != null && !me.equals(committerId)) { + if (committerId != null && haveApprovals.add(committerId)) { db.changeApprovals().insert( Collections.singleton(new ChangeApproval( new ChangeApproval.Key(change.getId(), committerId, catId), (short) 0)), txn); } + for (final Account.Id reviewer : reviewerId) { + if (haveApprovals.add(reviewer)) { + db.changeApprovals().insert( + Collections.singleton(new ChangeApproval( + new ChangeApproval.Key(change.getId(), reviewer, catId), + (short) 0)), txn); + } + } } final ChangeMessage msg =