Preserve negative approvals when replacing patch sets
Prior versions of Gerrit correctly saved a negative approval when a replacement patch set was uploaded. This was a specific feature we added to allow project leads to reject a change until they are satisfied with the replacement, even if other developers on that project were able to review and approve subsequent patch sets. Since approvals are now per-patch set we have to copy the approval records from the prior patch set to this one, if the value is < 0. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
@@ -98,6 +98,14 @@ public final class PatchSetApproval {
|
|||||||
setGranted();
|
setGranted();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PatchSetApproval(final PatchSet.Id psId, final PatchSetApproval src) {
|
||||||
|
key =
|
||||||
|
new PatchSetApproval.Key(psId, src.getAccountId(), src.getCategoryId());
|
||||||
|
changeOpen = true;
|
||||||
|
value = src.getValue();
|
||||||
|
granted = src.granted;
|
||||||
|
}
|
||||||
|
|
||||||
public PatchSetApproval.Key getKey() {
|
public PatchSetApproval.Key getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -810,6 +810,7 @@ final class Receive extends AbstractGitCommand {
|
|||||||
change = changeCache.get(changeId);
|
change = changeCache.get(changeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final PatchSet.Id priorPatchSet = change.currentPatchSetId();
|
||||||
final HashSet<ObjectId> existingRevisions = new HashSet<ObjectId>();
|
final HashSet<ObjectId> existingRevisions = new HashSet<ObjectId>();
|
||||||
for (final PatchSet ps : db.patchSets().byChange(changeId)) {
|
for (final PatchSet ps : db.patchSets().byChange(changeId)) {
|
||||||
if (ps.getRevision() != null) {
|
if (ps.getRevision() != null) {
|
||||||
@@ -893,6 +894,17 @@ final class Receive extends AbstractGitCommand {
|
|||||||
oldCC.add(a.getAccountId());
|
oldCC.add(a.getAccountId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (a.getValue() < 0
|
||||||
|
&& a.getPatchSetId().equals(priorPatchSet)) {
|
||||||
|
// If there was a negative vote on the prior patch set, carry it
|
||||||
|
// into this patch set.
|
||||||
|
//
|
||||||
|
db.patchSetApprovals()
|
||||||
|
.insert(
|
||||||
|
Collections.singleton(new PatchSetApproval(ps.getId(), a)),
|
||||||
|
txn);
|
||||||
|
}
|
||||||
|
|
||||||
if (!haveAuthor && authorId != null
|
if (!haveAuthor && authorId != null
|
||||||
&& a.getAccountId().equals(authorId)) {
|
&& a.getAccountId().equals(authorId)) {
|
||||||
haveAuthor = true;
|
haveAuthor = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user