Support move change via SSH
Change-Id: I64ec14bea8a81c439d51459462abd2fcfb7ae81d
This commit is contained in:
@@ -14,6 +14,7 @@ _ssh_ -p <port> <host> _gerrit review_
|
||||
[--submit | -s]
|
||||
[--abandon | --restore]
|
||||
[--rebase]
|
||||
[--move <BRANCH>]
|
||||
[--publish]
|
||||
[--json | -j]
|
||||
[--delete]
|
||||
@@ -66,7 +67,7 @@ branch.
|
||||
link:rest-api-changes.html#review-input[ReviewInput] entity for the
|
||||
format.
|
||||
(option is mutually exclusive with --submit, --restore, --publish, --delete,
|
||||
--abandon, --message and --rebase)
|
||||
--abandon, --message, --rebase and --move)
|
||||
|
||||
--notify::
|
||||
-n::
|
||||
@@ -88,7 +89,7 @@ branch.
|
||||
--abandon::
|
||||
Abandon the specified change(s).
|
||||
(option is mutually exclusive with --submit, --restore, --publish, --delete,
|
||||
--rebase and --json)
|
||||
--rebase, --move and --json)
|
||||
|
||||
--restore::
|
||||
Restore the specified abandoned change(s).
|
||||
@@ -98,6 +99,10 @@ branch.
|
||||
Rebase the specified change(s).
|
||||
(option is mutually exclusive with --abandon, --submit, --delete and --json)
|
||||
|
||||
--move::
|
||||
Move the specified change(s).
|
||||
(option is mutually exclusive with --json and --abandon)
|
||||
|
||||
--submit::
|
||||
-s::
|
||||
Submit the specified patch set(s) for merging.
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.google.gerrit.common.data.LabelValue;
|
||||
import com.google.gerrit.extensions.api.GerritApi;
|
||||
import com.google.gerrit.extensions.api.changes.AbandonInput;
|
||||
import com.google.gerrit.extensions.api.changes.ChangeApi;
|
||||
import com.google.gerrit.extensions.api.changes.MoveInput;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.api.changes.RestoreInput;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewInput;
|
||||
@@ -108,6 +109,9 @@ public class ReviewCommand extends SshCommand {
|
||||
@Option(name = "--rebase", usage = "rebase the specified change(s)")
|
||||
private boolean rebaseChange;
|
||||
|
||||
@Option(name = "--move", usage = "move the specified change(s)", metaVar = "BRANCH")
|
||||
private String moveToBranch;
|
||||
|
||||
@Option(name = "--submit", aliases = "-s", usage = "submit the specified patch set(s)")
|
||||
private boolean submitChange;
|
||||
|
||||
@@ -167,6 +171,9 @@ public class ReviewCommand extends SshCommand {
|
||||
if (rebaseChange) {
|
||||
throw die("abandon and rebase actions are mutually exclusive");
|
||||
}
|
||||
if (moveToBranch != null) {
|
||||
throw die("abandon and move actions are mutually exclusive");
|
||||
}
|
||||
}
|
||||
if (publishPatchSet) {
|
||||
if (restoreChange) {
|
||||
@@ -201,6 +208,9 @@ public class ReviewCommand extends SshCommand {
|
||||
if (rebaseChange) {
|
||||
throw die("json and rebase actions are mutually exclusive");
|
||||
}
|
||||
if (moveToBranch != null) {
|
||||
throw die("json and move actions are mutually exclusive");
|
||||
}
|
||||
if (changeTag != null) {
|
||||
throw die("json and tag actions are mutually exclusive");
|
||||
}
|
||||
@@ -289,7 +299,7 @@ public class ReviewCommand extends SshCommand {
|
||||
review.labels.putAll(customLabels);
|
||||
|
||||
// We don't need to add the review comment when abandoning/restoring.
|
||||
if (abandonChange || restoreChange) {
|
||||
if (abandonChange || restoreChange || moveToBranch != null) {
|
||||
review.message = null;
|
||||
}
|
||||
|
||||
@@ -308,6 +318,13 @@ public class ReviewCommand extends SshCommand {
|
||||
applyReview(patchSet, review);
|
||||
}
|
||||
|
||||
if (moveToBranch != null) {
|
||||
MoveInput moveInput = new MoveInput();
|
||||
moveInput.destinationBranch = moveToBranch;
|
||||
moveInput.message = Strings.emptyToNull(changeComment);
|
||||
changeApi(patchSet).move(moveInput);
|
||||
}
|
||||
|
||||
if (rebaseChange) {
|
||||
revisionApi(patchSet).rebase();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user