Search in sources :

Example 16 with ChangeApi

use of com.google.gerrit.extensions.api.changes.ChangeApi 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 = getRemoteHead();
    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)

Example 17 with ChangeApi

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

the class SubmitByMergeIfNecessaryIT method openChangeForTargetBranchPreventsMerge.

@Test
public void openChangeForTargetBranchPreventsMerge() throws Exception {
    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(db, user.getIdent(), 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().getParentKey().get() + ": depends on change that was not submitted");
    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)

Aggregations

ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)17 Test (org.junit.Test)17 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)15 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)12 CherryPickInput (com.google.gerrit.extensions.api.changes.CherryPickInput)10 BranchInput (com.google.gerrit.extensions.api.projects.BranchInput)7 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)5 RefSpec (org.eclipse.jgit.transport.RefSpec)4 ChangeInput (com.google.gerrit.extensions.common.ChangeInput)3 ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)3 RevCommit (org.eclipse.jgit.revwalk.RevCommit)3 RevisionInfo (com.google.gerrit.extensions.common.RevisionInfo)2 BinaryResult (com.google.gerrit.extensions.restapi.BinaryResult)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectId (org.eclipse.jgit.lib.ObjectId)2 Result (com.google.gerrit.acceptance.PushOneCommit.Result)1 RevisionApi (com.google.gerrit.extensions.api.changes.RevisionApi)1 Project (com.google.gerrit.reviewdb.client.Project)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1