Clear any ChangeApprovals already placed when adding a patch set

This way an ACK on patch set 1 doesn't allow a submitter to
upload a pack set 2, bypass the ACK status, and jump right
to the submission queue.

We only clear positive ACKs under the assumption that a
negative one has good reason to stand, and may need to be
resolved manually.  Clearing positive ACKs just denies the
"replace and submit" hole in the workflow.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-01-05 17:25:24 -08:00
parent 800cad53c9
commit e0ffe1f6f6

View File

@@ -20,6 +20,7 @@ import com.google.gerrit.client.reviewdb.AccountAgreement;
import com.google.gerrit.client.reviewdb.AccountExternalId;
import com.google.gerrit.client.reviewdb.Branch;
import com.google.gerrit.client.reviewdb.Change;
import com.google.gerrit.client.reviewdb.ChangeApproval;
import com.google.gerrit.client.reviewdb.ContactInformation;
import com.google.gerrit.client.reviewdb.ContributorAgreement;
import com.google.gerrit.client.reviewdb.PatchSet;
@@ -501,6 +502,17 @@ class Receive extends AbstractGitCommand {
final PatchSetImporter imp = new PatchSetImporter(db, repo, c, ps, true);
imp.setTransaction(txn);
imp.run();
for (final ChangeApproval a : db.changeApprovals().byChange(change.getId())) {
if (userAccount.getId().equals(a.getAccountId())) {
// Leave my own approvals alone.
} else if (a.getValue() > 0) {
a.clear();
db.changeApprovals().update(Collections.singleton(a));
}
}
change.setCurrentPatchSet(imp.getPatchSetInfo());
change.updated();
db.changes().update(Collections.singleton(change));