Clarify and test Change-Id behavior for cherry-pick
Change-Id: Ib5302ad4b97dd799d725bd94ae3b53835c6eaa32
This commit is contained in:
		@@ -4786,7 +4786,8 @@ Deletes the reviewed flag of the calling user from a file of a revision.
 | 
			
		||||
Cherry picks a revision to a destination branch.
 | 
			
		||||
 | 
			
		||||
The commit message and destination branch must be provided in the request body inside a
 | 
			
		||||
link:#cherrypick-input[CherryPickInput] entity.
 | 
			
		||||
link:#cherrypick-input[CherryPickInput] entity.  If the commit message
 | 
			
		||||
does not specify a Change-Id, a new one is picked for the destination change.
 | 
			
		||||
 | 
			
		||||
.Request
 | 
			
		||||
----
 | 
			
		||||
 
 | 
			
		||||
@@ -325,6 +325,28 @@ public class RevisionIT extends AbstractDaemonTest {
 | 
			
		||||
    cherry.current().submit();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void cherryPickSetChangeId() throws Exception {
 | 
			
		||||
    PushOneCommit.Result r = pushTo("refs/for/master");
 | 
			
		||||
    CherryPickInput in = new CherryPickInput();
 | 
			
		||||
    in.destination = "foo";
 | 
			
		||||
    String id = "Ideadbeefdeadbeefdeadbeefdeadbeefdeadbe3f";
 | 
			
		||||
    in.message = "it goes to foo branch\n\nChange-Id: " + id;
 | 
			
		||||
 | 
			
		||||
    gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());
 | 
			
		||||
    ChangeApi orig = gApi.changes().id(project.get() + "~master~" + r.getChangeId());
 | 
			
		||||
 | 
			
		||||
    assertThat(orig.get().messages).hasSize(1);
 | 
			
		||||
    ChangeApi cherry = orig.revision(r.getCommit().name()).cherryPick(in);
 | 
			
		||||
 | 
			
		||||
    ChangeInfo changeInfo = cherry.get();
 | 
			
		||||
 | 
			
		||||
    // The cherry-pick honors the ChangeId specified in the input message:
 | 
			
		||||
    RevisionInfo revInfo = changeInfo.revisions.get(changeInfo.currentRevision);
 | 
			
		||||
    assertThat(revInfo).isNotNull();
 | 
			
		||||
    assertThat(revInfo.commit.message).endsWith(id + "\n");
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Test
 | 
			
		||||
  public void cherryPickwithNoTopic() throws Exception {
 | 
			
		||||
    PushOneCommit.Result r = pushTo("refs/for/master");
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user