Option for SSHD review-cmd to always publish the message.
"--force-message" option for the SSHD review command, which allows Gerrit to publish the "--message", even if the labels could not be applied due to change being closed. Used by some scripts/CI-systems, where the results (or links to the result) are posted as a message after completion of a build (often together with a label-change, indicating the success of the build). If the message is posted successfully, the cmd will return successfully, even if the label could not be changed. Change-Id: Ic2d5fc25ba97ddcedce832c7444e4f07512c761c
This commit is contained in:

committed by
Shawn O. Pearce

parent
6cc0abd4ca
commit
1fbf2c28a0
@@ -11,6 +11,7 @@ SYNOPSIS
|
|||||||
'ssh' -p <port> <host> 'gerrit review'
|
'ssh' -p <port> <host> 'gerrit review'
|
||||||
[--project <PROJECT>]
|
[--project <PROJECT>]
|
||||||
[--message <MESSAGE>]
|
[--message <MESSAGE>]
|
||||||
|
[--force-message]
|
||||||
[--submit]
|
[--submit]
|
||||||
[--abandon | --restore]
|
[--abandon | --restore]
|
||||||
[--verified <N>] [--code-review <N>]
|
[--verified <N>] [--code-review <N>]
|
||||||
@@ -47,6 +48,19 @@ OPTIONS
|
|||||||
Optional cover letter to include as part of the message
|
Optional cover letter to include as part of the message
|
||||||
sent to reviewers when the approval states are updated.
|
sent to reviewers when the approval states are updated.
|
||||||
|
|
||||||
|
--force-message::
|
||||||
|
Option which allows Gerrit to publish the --message, even
|
||||||
|
when the labels could not be applied due to change being
|
||||||
|
closed).
|
||||||
|
+
|
||||||
|
Used by some scripts/CI-systems, where the results (or links
|
||||||
|
to the result) are posted as a message after completion of a
|
||||||
|
build (often together with a label-change, indicating the success
|
||||||
|
of the build).
|
||||||
|
+
|
||||||
|
If the message is posted successfully, the cmd will return
|
||||||
|
successfully, even if the label could not be changed.
|
||||||
|
|
||||||
--help::
|
--help::
|
||||||
-h::
|
-h::
|
||||||
Display site-specific usage information, including the
|
Display site-specific usage information, including the
|
||||||
|
@@ -136,7 +136,7 @@ class PatchDetailServiceImpl extends BaseServiceImplementation implements
|
|||||||
public void publishComments(final PatchSet.Id psid, final String msg,
|
public void publishComments(final PatchSet.Id psid, final String msg,
|
||||||
final Set<ApprovalCategoryValue.Id> tags,
|
final Set<ApprovalCategoryValue.Id> tags,
|
||||||
final AsyncCallback<VoidResult> cb) {
|
final AsyncCallback<VoidResult> cb) {
|
||||||
Handler.wrap(publishCommentsFactory.create(psid, msg, tags)).to(cb);
|
Handler.wrap(publishCommentsFactory.create(psid, msg, tags, false)).to(cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -57,7 +57,7 @@ public class PublishComments implements Callable<VoidResult> {
|
|||||||
|
|
||||||
public interface Factory {
|
public interface Factory {
|
||||||
PublishComments create(PatchSet.Id patchSetId, String messageText,
|
PublishComments create(PatchSet.Id patchSetId, String messageText,
|
||||||
Set<ApprovalCategoryValue.Id> approvals);
|
Set<ApprovalCategoryValue.Id> approvals, boolean forceMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ReviewDb db;
|
private final ReviewDb db;
|
||||||
@@ -72,6 +72,7 @@ public class PublishComments implements Callable<VoidResult> {
|
|||||||
private final PatchSet.Id patchSetId;
|
private final PatchSet.Id patchSetId;
|
||||||
private final String messageText;
|
private final String messageText;
|
||||||
private final Set<ApprovalCategoryValue.Id> approvals;
|
private final Set<ApprovalCategoryValue.Id> approvals;
|
||||||
|
private final boolean forceMessage;
|
||||||
|
|
||||||
private Change change;
|
private Change change;
|
||||||
private PatchSet patchSet;
|
private PatchSet patchSet;
|
||||||
@@ -89,7 +90,8 @@ public class PublishComments implements Callable<VoidResult> {
|
|||||||
|
|
||||||
@Assisted final PatchSet.Id patchSetId,
|
@Assisted final PatchSet.Id patchSetId,
|
||||||
@Assisted final String messageText,
|
@Assisted final String messageText,
|
||||||
@Assisted final Set<ApprovalCategoryValue.Id> approvals) {
|
@Assisted final Set<ApprovalCategoryValue.Id> approvals,
|
||||||
|
@Assisted final boolean forceMessage) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.types = approvalTypes;
|
this.types = approvalTypes;
|
||||||
@@ -102,6 +104,7 @@ public class PublishComments implements Callable<VoidResult> {
|
|||||||
this.patchSetId = patchSetId;
|
this.patchSetId = patchSetId;
|
||||||
this.messageText = messageText;
|
this.messageText = messageText;
|
||||||
this.approvals = approvals;
|
this.approvals = approvals;
|
||||||
|
this.forceMessage = forceMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -123,10 +126,10 @@ public class PublishComments implements Callable<VoidResult> {
|
|||||||
final boolean isCurrent = patchSetId.equals(change.currentPatchSetId());
|
final boolean isCurrent = patchSetId.equals(change.currentPatchSetId());
|
||||||
if (isCurrent && change.getStatus().isOpen()) {
|
if (isCurrent && change.getStatus().isOpen()) {
|
||||||
publishApprovals(ctl);
|
publishApprovals(ctl);
|
||||||
} else if (!approvals.isEmpty()) {
|
} else if (approvals.isEmpty() || forceMessage) {
|
||||||
throw new InvalidChangeOperationException("Change is closed");
|
|
||||||
} else {
|
|
||||||
publishMessageOnly();
|
publishMessageOnly();
|
||||||
|
} else {
|
||||||
|
throw new InvalidChangeOperationException("Change is closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
touchChange();
|
touchChange();
|
||||||
|
@@ -100,6 +100,10 @@ public class ReviewCommand extends BaseCommand {
|
|||||||
@Option(name = "--submit", aliases = "-s", usage = "submit the patch set")
|
@Option(name = "--submit", aliases = "-s", usage = "submit the patch set")
|
||||||
private boolean submitChange;
|
private boolean submitChange;
|
||||||
|
|
||||||
|
@Option(name = "--force-message", usage = "publish the message, "
|
||||||
|
+ "even if the label score cannot be applied due to change being closed")
|
||||||
|
private boolean forceMessage = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ReviewDb db;
|
private ReviewDb db;
|
||||||
|
|
||||||
@@ -227,7 +231,7 @@ public class ReviewCommand extends BaseCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
publishCommentsFactory.create(patchSetId, changeComment, aps).call();
|
publishCommentsFactory.create(patchSetId, changeComment, aps, forceMessage).call();
|
||||||
|
|
||||||
if (abandonChange) {
|
if (abandonChange) {
|
||||||
if (changeControl.canAbandon()) {
|
if (changeControl.canAbandon()) {
|
||||||
|
Reference in New Issue
Block a user