Add --rebase option to review command
Feature: issue 2824
Change-Id: Ibb5bc553fea1ad9dd43a69145f27645dc33c5e52
diff --git a/Documentation/cmd-review.txt b/Documentation/cmd-review.txt
index 12d91ae..70a695e 100644
--- a/Documentation/cmd-review.txt
+++ b/Documentation/cmd-review.txt
@@ -13,6 +13,7 @@
[--notify <NOTIFYHANDLING> | -n <NOTIFYHANDLING>]
[--submit | -s]
[--abandon | --restore]
+ [--rebase]
[--publish]
[--json | -j]
[--delete]
@@ -64,7 +65,7 @@
link:rest-api-changes.html#review-input[ReviewInput] entity for the
format.
(option is mutually exclusive with --submit, --restore, --publish, --delete,
- --abandon and --message)
+ --abandon, --message and --rebase)
--notify::
-n::
@@ -85,17 +86,22 @@
--abandon::
Abandon the specified change(s).
- (option is mutually exclusive with --submit, --restore, --publish, --delete
- and --json)
+ (option is mutually exclusive with --submit, --restore, --publish, --delete,
+ --rebase and --json)
--restore::
Restore the specified abandoned change(s).
(option is mutually exclusive with --abandon and --json)
+--rebase::
+ Rebase the specified change(s).
+ (option is mutually exclusive with --abandon, --submit, --delete and --json)
+
--submit::
-s::
Submit the specified patch set(s) for merging.
- (option is mutually exclusive with --abandon, --publish --delete and --json)
+ (option is mutually exclusive with --abandon, --publish --delete, --rebase
+ and --json)
--publish::
Publish the specified draft patch set(s).
@@ -104,8 +110,8 @@
--delete::
Delete the specified draft patch set(s).
- (option is mutually exclusive with --submit, --restore, --abandon, --publish
- and --json)
+ (option is mutually exclusive with --submit, --restore, --abandon, --publish,
+ --rebase and --json)
--code-review::
--verified::
diff --git a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/ReviewCommand.java b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/ReviewCommand.java
index f85b1b3..7753961 100644
--- a/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/ReviewCommand.java
+++ b/gerrit-sshd/src/main/java/com/google/gerrit/sshd/commands/ReviewCommand.java
@@ -105,6 +105,9 @@
@Option(name = "--restore", usage = "restore the specified abandoned change(s)")
private boolean restoreChange;
+ @Option(name = "--rebase", usage = "rebase the specified change(s)")
+ private boolean rebaseChange;
+
@Option(name = "--submit", aliases = "-s", usage = "submit the specified patch set(s)")
private boolean submitChange;
@@ -154,6 +157,9 @@
if (deleteDraftPatchSet) {
throw error("abandon and delete actions are mutually exclusive");
}
+ if (rebaseChange) {
+ throw error("abandon and rebase actions are mutually exclusive");
+ }
}
if (publishPatchSet) {
if (restoreChange) {
@@ -185,6 +191,17 @@
if (changeComment != null) {
throw error("json and message are mutually exclusive");
}
+ if (rebaseChange) {
+ throw error("json and rebase actions are mutually exclusive");
+ }
+ }
+ if (rebaseChange) {
+ if (deleteDraftPatchSet) {
+ throw error("rebase and delete actions are mutually exclusive");
+ }
+ if (submitChange) {
+ throw error("rebase and submit actions are mutually exclusive");
+ }
}
if (deleteDraftPatchSet && submitChange) {
throw error("delete and submit actions are mutually exclusive");
@@ -285,6 +302,10 @@
applyReview(patchSet, review);
}
+ if (rebaseChange){
+ revisionApi(patchSet).rebase();
+ }
+
if (submitChange) {
revisionApi(patchSet).submit();
}