Search in sources :

Example 56 with CherryPickInput

use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.

the class SubmitByMergeIfNecessaryIT method openChangeForTargetBranchPreventsMerge.

@Test
public void openChangeForTargetBranchPreventsMerge() throws Throwable {
    gApi.projects().name(project.get()).branch("stable").create(new BranchInput());
    // Propose a change for master, but leave it open for master!
    PushOneCommit change = pushFactory.create(user.newIdent(), testRepo, "small fix", "a.txt", "2");
    PushOneCommit.Result change2result = change.to("refs/for/master");
    // Now cherry pick to stable
    CherryPickInput in = new CherryPickInput();
    in.destination = "stable";
    in.message = "it goes to stable branch";
    ChangeApi orig = gApi.changes().id(change2result.getChangeId());
    ChangeApi cherry = orig.current().cherryPick(in);
    cherry.current().review(ReviewInput.approve());
    cherry.current().submit();
    // Create a commit locally
    testRepo.git().fetch().setRefSpecs(new RefSpec("refs/heads/stable")).call();
    PushOneCommit.Result change3 = createChange(testRepo, "stable", "test", "a.txt", "3", "");
    submitWithConflict(change3.getChangeId(), "Failed to submit 1 change due to the following problems:\n" + "Change " + change3.getPatchSetId().changeId().get() + ": Depends on change that was not submitted." + " Commit " + change3.getCommit().name() + " depends on commit " + change2result.getCommit().name() + " of change " + change2result.getChange().getId() + " which cannot be merged.");
    assertRefUpdatedEvents();
    assertChangeMergedEvents();
}
Also used : RefSpec(org.eclipse.jgit.transport.RefSpec) ChangeApi(com.google.gerrit.extensions.api.changes.ChangeApi) CherryPickInput(com.google.gerrit.extensions.api.changes.CherryPickInput) BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test)

Example 57 with CherryPickInput

use of com.google.gerrit.extensions.api.changes.CherryPickInput in project gerrit by GerritCodeReview.

the class CreateChangeIT method onlyContentMerged.

@Test
public void onlyContentMerged() throws Exception {
    testRepo.branch("HEAD").commit().insertChangeId().message("first commit").add("a.txt", "a contents ").create();
    testRepo.git().push().setRemote("origin").setRefSpecs(new RefSpec("HEAD:refs/heads/master")).call();
    // create a change, and cherrypick into master
    PushOneCommit.Result cId = createChange();
    RevCommit commitId = cId.getCommit();
    CherryPickInput cpi = new CherryPickInput();
    cpi.destination = "master";
    cpi.message = "cherry pick the commit";
    ChangeApi orig = gApi.changes().id(cId.getChangeId());
    ChangeApi cherry = orig.current().cherryPick(cpi);
    cherry.current().review(ReviewInput.approve());
    cherry.current().submit();
    ObjectId remoteId = projectOperations.project(project).getHead("master");
    assertThat(remoteId).isNotEqualTo(commitId);
    ChangeInput in = newMergeChangeInput("master", commitId.getName(), "");
    assertCreateSucceeds(in);
}
Also used : Result(com.google.gerrit.acceptance.PushOneCommit.Result) RefSpec(org.eclipse.jgit.transport.RefSpec) ChangeApi(com.google.gerrit.extensions.api.changes.ChangeApi) ObjectId(org.eclipse.jgit.lib.ObjectId) CherryPickInput(com.google.gerrit.extensions.api.changes.CherryPickInput) ChangeInput(com.google.gerrit.extensions.common.ChangeInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Aggregations

CherryPickInput (com.google.gerrit.extensions.api.changes.CherryPickInput)57 Test (org.junit.Test)53 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)50 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)49 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)30 BranchInput (com.google.gerrit.extensions.api.projects.BranchInput)27 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)22 RevCommit (org.eclipse.jgit.revwalk.RevCommit)15 ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)11 RevisionInfo (com.google.gerrit.extensions.common.RevisionInfo)11 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)8 Result (com.google.gerrit.acceptance.PushOneCommit.Result)7 ObjectId (org.eclipse.jgit.lib.ObjectId)7 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)6 RefSpec (org.eclipse.jgit.transport.RefSpec)5 CommitInfo (com.google.gerrit.extensions.common.CommitInfo)3 FileInfo (com.google.gerrit.extensions.common.FileInfo)3 AuthException (com.google.gerrit.extensions.restapi.AuthException)3 Iterables (com.google.common.collect.Iterables)2 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)2