Allow gerrit approve to post comments on closed changes

The web UI permits comments on closed changes, so we should do the
same thing with the SSH based approve command.  However like the
web we need to ignore the vote flags if its closed, as those cannot
be changed.

Bug: issue 488
Change-Id: I366b41785eea27b939f44ea2c2613a8d67a57001
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2010-03-04 17:53:51 -08:00
parent 44a80aa4b5
commit 7c50423e77

View File

@@ -151,9 +151,6 @@ public class ApproveCommand extends BaseCommand {
final ChangeControl changeControl = final ChangeControl changeControl =
changeControlFactory.validateFor(changeId); changeControlFactory.validateFor(changeId);
final Change change = changeControl.getChange(); final Change change = changeControl.getChange();
if (change.getStatus().isClosed()) {
throw error("change " + changeId + " is closed");
}
final StringBuffer msgBuf = new StringBuffer(); final StringBuffer msgBuf = new StringBuffer();
msgBuf.append("Patch Set "); msgBuf.append("Patch Set ");
@@ -163,6 +160,7 @@ public class ApproveCommand extends BaseCommand {
final Map<ApprovalCategory.Id, ApprovalCategoryValue.Id> approvalsMap = final Map<ApprovalCategory.Id, ApprovalCategoryValue.Id> approvalsMap =
new HashMap<ApprovalCategory.Id, ApprovalCategoryValue.Id>(); new HashMap<ApprovalCategory.Id, ApprovalCategoryValue.Id>();
if (change.getStatus().isOpen()) {
for (ApproveOption co : optionList) { for (ApproveOption co : optionList) {
final ApprovalCategory.Id category = co.getCategoryId(); final ApprovalCategory.Id category = co.getCategoryId();
PatchSetApproval.Key psaKey = PatchSetApproval.Key psaKey =
@@ -190,6 +188,7 @@ public class ApproveCommand extends BaseCommand {
msgBuf.append(" " + message + ";"); msgBuf.append(" " + message + ";");
approvalsMap.put(category, val); approvalsMap.put(category, val);
} }
}
msgBuf.deleteCharAt(msgBuf.length() - 1); msgBuf.deleteCharAt(msgBuf.length() - 1);
msgBuf.append("\n\n"); msgBuf.append("\n\n");