Fail review command for changing labels when change is closed

If a reviewer attempts to change a review label (approval)
after a change is closed using the ssh review command, cause
it to fail the command and output a message.

Change-Id: Ibdaf82652bb07761203e18a07c0c3306e60c21ff
This commit is contained in:
Martin Fick
2011-06-16 18:32:22 -06:00
parent e01f37016d
commit ec9a6e4439
2 changed files with 7 additions and 3 deletions

View File

@@ -30,6 +30,7 @@ import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.mail.CommentSender;
import com.google.gerrit.server.mail.EmailException;
import com.google.gerrit.server.project.ChangeControl;
import com.google.gerrit.server.project.InvalidChangeOperationException;
import com.google.gerrit.server.project.NoSuchChangeException;
import com.google.gerrit.server.workflow.FunctionState;
import com.google.gwtjsonrpc.client.VoidResult;
@@ -104,7 +105,8 @@ public class PublishComments implements Callable<VoidResult> {
}
@Override
public VoidResult call() throws NoSuchChangeException, OrmException {
public VoidResult call() throws NoSuchChangeException,
InvalidChangeOperationException, OrmException {
final Change.Id changeId = patchSetId.getParentKey();
final ChangeControl ctl = changeControlFactory.validateFor(changeId);
change = ctl.getChange();
@@ -119,6 +121,8 @@ public class PublishComments implements Callable<VoidResult> {
final boolean isCurrent = patchSetId.equals(change.currentPatchSetId());
if (isCurrent && change.getStatus().isOpen()) {
publishApprovals();
} else if (! approvals.isEmpty()) {
throw new InvalidChangeOperationException("Change is closed");
} else {
publishMessageOnly();
}