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:
		| @@ -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(); | ||||
|     } | ||||
|   | ||||
| @@ -222,9 +222,9 @@ public class ReviewCommand extends BaseCommand { | ||||
|       } | ||||
|     } | ||||
|  | ||||
|     publishCommentsFactory.create(patchSetId, changeComment, aps).call(); | ||||
|  | ||||
|     try { | ||||
|       publishCommentsFactory.create(patchSetId, changeComment, aps).call(); | ||||
|  | ||||
|       if (abandonChange) { | ||||
|         if (changeControl.canAbandon()) { | ||||
|           ChangeUtil.abandon(patchSetId, currentUser, changeComment, db, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Martin Fick
					Martin Fick