Mark cherry-pick change as WIP if source change is WIP
If a work-in-progress change is cherry-picked to another branch the
cherry-pick change should be marked as work-in-progress too.
Change-Id: Ib9646ca65ea6ecabc596ef884edf1e6d9932596c
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/java/com/google/gerrit/server/restapi/change/CherryPickChange.java b/java/com/google/gerrit/server/restapi/change/CherryPickChange.java
index 94b58ec..b78c527 100644
--- a/java/com/google/gerrit/server/restapi/change/CherryPickChange.java
+++ b/java/com/google/gerrit/server/restapi/change/CherryPickChange.java
@@ -369,7 +369,9 @@
messageForDestinationChange(
ins.getPatchSetId(), sourceBranch, sourceCommit, cherryPickCommit))
.setTopic(topic)
- .setWorkInProgress(!cherryPickCommit.getFilesWithGitConflicts().isEmpty())
+ .setWorkInProgress(
+ (sourceChange != null && sourceChange.isWorkInProgress())
+ || !cherryPickCommit.getFilesWithGitConflicts().isEmpty())
.setNotify(input.notify)
.setAccountsToNotify(notifyUtil.resolveAccounts(input.notifyDetails));
if (input.keepReviewers && sourceChange != null) {
diff --git a/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java b/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
index 94a2796..df0facd 100644
--- a/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
+++ b/javatests/com/google/gerrit/acceptance/api/revision/RevisionIT.java
@@ -389,6 +389,19 @@
}
@Test
+ public void cherryPickWorkInProgressChange() throws Exception {
+ PushOneCommit.Result r = pushTo("refs/for/master%wip");
+ CherryPickInput in = new CherryPickInput();
+ in.destination = "foo";
+ in.message = "cherry pick message";
+ gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());
+ ChangeApi orig = gApi.changes().id(project.get() + "~master~" + r.getChangeId());
+
+ ChangeApi cherry = orig.revision(r.getCommit().name()).cherryPick(in);
+ assertThat(cherry.get().workInProgress).isTrue();
+ }
+
+ @Test
public void cherryPickToSameBranch() throws Exception {
PushOneCommit.Result r = createChange();
CherryPickInput in = new CherryPickInput();