summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOrgad Shaneh <orgad.shaneh@audiocodes.com>2021-08-30 10:35:40 +0300
committerOrgad Shaneh <orgad.shaneh@audiocodes.com>2021-08-30 18:34:18 +0300
commitde3e31297f4eb8f6d1428df3b04c456134da0b61 (patch)
tree543d6063337918b6e66efbb2b4c135eb64fa4707
parent6cc56e96c22743ade41f04ceccae3c93307ee422 (diff)
Allow moving of merge commits
There is no good reason to block it. If a merge was targetting branch A, but then it was decided to create a new branch for this merge named B, which starts from A - The merge is still valid for B, and the user has no way to move it without amending and creating a new change. Bug: Issue 7338 Bug: Issue 9812 Change-Id: Ie9e50c9cec60549f3abc2b9ed62b9912fa7bc9ab
-rw-r--r--Documentation/intro-user.txt2
-rw-r--r--java/com/google/gerrit/server/restapi/change/Move.java3
-rw-r--r--javatests/com/google/gerrit/acceptance/rest/change/MoveChangeIT.java8
3 files changed, 4 insertions, 9 deletions
diff --git a/Documentation/intro-user.txt b/Documentation/intro-user.txt
index eb2025c980..9909aac0ed 100644
--- a/Documentation/intro-user.txt
+++ b/Documentation/intro-user.txt
@@ -459,7 +459,7 @@ abandon permission] on the change and link:access-control.html#category_push[
push permission] on the destination branch.
The move operation will not update the change's parent and users will have
-to link:#rebase[rebase] the change. Also, merge commits cannot be moved.
+to link:#rebase[rebase] the change.
[[abandon]]
[[restore]]
diff --git a/java/com/google/gerrit/server/restapi/change/Move.java b/java/com/google/gerrit/server/restapi/change/Move.java
index c109cbf3fb..daa95c4225 100644
--- a/java/com/google/gerrit/server/restapi/change/Move.java
+++ b/java/com/google/gerrit/server/restapi/change/Move.java
@@ -191,9 +191,6 @@ public class Move implements RestModifyView<ChangeResource, MoveInput>, UiAction
RevWalk revWalk = new RevWalk(repo)) {
RevCommit currPatchsetRevCommit =
revWalk.parseCommit(psUtil.current(ctx.getNotes()).commitId());
- if (currPatchsetRevCommit.getParentCount() > 1) {
- throw new ResourceConflictException("Merge commit cannot be moved");
- }
ObjectId refId = repo.resolve(input.destinationBranch);
// Check if destination ref exists in project repo
diff --git a/javatests/com/google/gerrit/acceptance/rest/change/MoveChangeIT.java b/javatests/com/google/gerrit/acceptance/rest/change/MoveChangeIT.java
index 37b17130fa..7df45733ea 100644
--- a/javatests/com/google/gerrit/acceptance/rest/change/MoveChangeIT.java
+++ b/javatests/com/google/gerrit/acceptance/rest/change/MoveChangeIT.java
@@ -169,11 +169,9 @@ public class MoveChangeIT extends AbstractDaemonTest {
BranchNameKey newBranch =
BranchNameKey.create(r1.getChange().change().getProject(), "moveTest");
createBranch(newBranch);
- ResourceConflictException thrown =
- assertThrows(
- ResourceConflictException.class,
- () -> move(GitUtil.getChangeId(testRepo, c).get(), newBranch.branch()));
- assertThat(thrown).hasMessageThat().contains("Merge commit cannot be moved");
+ String changeId = GitUtil.getChangeId(testRepo, c).get();
+ move(changeId, newBranch.branch());
+ assertThat(gApi.changes().id(changeId).get().branch).isEqualTo("moveTest");
}
@Test