InlineEdit: Allow to upload change edit with git push

Edits can already be pulled with download commands. This change allows
edit to be pushed to gerrit by using magic branch %edit option.

Change must already exist for edit to be created/replaced. One use case
where edit might need to be replaced with git operations is rebasing of
edits on new patch set, in which case two refs are affected: old ref is
deleted and new ref is created:

  $ git push g HEAD:refs/for/master%e
  Counting objects: 14, done.
  [...]
  remote: Processing changes: updated: 1, refs: 2, done
  remote:
  remote: Updated Changes:
  remote:   http://localhost:8080/42 Fix typo in the doc [EDIT]

Change-Id: I3dbf66f1700c212ab90acfa77a5bd1e774b94555
This commit is contained in:
David Ostrovsky
2015-01-19 07:43:44 +01:00
parent ba5c957fae
commit d07bb33996
5 changed files with 153 additions and 10 deletions

View File

@@ -23,6 +23,7 @@ import com.google.gerrit.acceptance.AbstractDaemonTest;
import com.google.gerrit.acceptance.PushOneCommit;
import com.google.gerrit.acceptance.TestAccount;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.extensions.common.EditInfo;
import com.google.gerrit.extensions.common.LabelInfo;
import com.google.gerrit.extensions.restapi.RestApiException;
import com.google.gerrit.reviewdb.client.Change;
@@ -162,6 +163,21 @@ public abstract class AbstractPushForReview extends AbstractDaemonTest {
r.assertChange(Change.Status.DRAFT, null);
}
@Test
public void testPushForMasterAsEdit() throws GitAPIException,
IOException, RestApiException {
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
EditInfo edit = getEdit(r.getChangeId());
assertThat(edit).isNull();
// specify edit as option
r = amendChange(r.getChangeId(), "refs/for/master%edit");
r.assertOkStatus();
edit = getEdit(r.getChangeId());
assertThat(edit).isNotNull();
}
@Test
public void testPushForMasterWithApprovals() throws GitAPIException,
IOException, RestApiException {