Search in sources :

Example 26 with BranchInput

use of com.google.gerrit.extensions.api.projects.BranchInput in project gerrit by GerritCodeReview.

the class SubmitByMergeIfNecessaryIT method submitWithMergedAncestorsOnOtherBranch.

@Test
public void submitWithMergedAncestorsOnOtherBranch() throws Exception {
    RevCommit initialHead = getRemoteHead();
    PushOneCommit.Result change1 = createChange(testRepo, "master", "base commit", "a.txt", "1", "");
    submit(change1.getChangeId());
    RevCommit headAfterFirstSubmit = getRemoteHead();
    gApi.projects().name(project.get()).branch("branch").create(new BranchInput());
    PushOneCommit.Result change2 = createChange(testRepo, "master", "We want to commit this to master first", "a.txt", "2", "");
    submit(change2.getChangeId());
    RevCommit headAfterSecondSubmit = getRemoteLog(project, "master").get(0);
    assertThat(headAfterSecondSubmit.getShortMessage()).isEqualTo(change2.getCommit().getShortMessage());
    RevCommit tip2 = getRemoteLog(project, "branch").get(0);
    assertThat(tip2.getShortMessage()).isEqualTo(change1.getCommit().getShortMessage());
    PushOneCommit.Result change3 = createChange(testRepo, "branch", "This commit is based on master, which includes change2, " + "but is targeted at branch, which doesn't include it.", "a.txt", "3", "");
    submit(change3.getChangeId());
    List<RevCommit> log3 = getRemoteLog(project, "branch");
    assertThat(log3.get(0).getShortMessage()).isEqualTo(change3.getCommit().getShortMessage());
    assertThat(log3.get(1).getShortMessage()).isEqualTo(change2.getCommit().getShortMessage());
    assertRefUpdatedEvents(initialHead, headAfterFirstSubmit, headAfterFirstSubmit, headAfterSecondSubmit);
    assertChangeMergedEvents(change1.getChangeId(), headAfterFirstSubmit.name(), change2.getChangeId(), headAfterSecondSubmit.name());
}
Also used : BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) Test(org.junit.Test)

Example 27 with BranchInput

use of com.google.gerrit.extensions.api.projects.BranchInput in project gerrit by GerritCodeReview.

the class CheckMergeabilityIT method setUp.

@Before
public void setUp() throws Exception {
    branch = new Branch.NameKey(project, "test");
    gApi.projects().name(branch.getParentKey().get()).branch(branch.get()).create(new BranchInput());
}
Also used : Branch(com.google.gerrit.reviewdb.client.Branch) BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) Before(org.junit.Before)

Example 28 with BranchInput

use of com.google.gerrit.extensions.api.projects.BranchInput in project gerrit by GerritCodeReview.

the class CreateBranchIT method assertCreateFails.

private void assertCreateFails(Class<? extends RestApiException> errType) throws Exception {
    exception.expect(errType);
    branch().create(new BranchInput());
}
Also used : BranchInput(com.google.gerrit.extensions.api.projects.BranchInput)

Example 29 with BranchInput

use of com.google.gerrit.extensions.api.projects.BranchInput in project gerrit by GerritCodeReview.

the class DeleteBranchIT method setUp.

@Before
public void setUp() throws Exception {
    project = createProject(name("p"));
    branch = new Branch.NameKey(project, "test");
    branch().create(new BranchInput());
}
Also used : Branch(com.google.gerrit.reviewdb.client.Branch) BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) Before(org.junit.Before)

Example 30 with BranchInput

use of com.google.gerrit.extensions.api.projects.BranchInput in project gerrit by GerritCodeReview.

the class CreateBranchCommand method run.

@Override
protected void run() throws UnloggedFailure {
    try {
        BranchInput in = new BranchInput();
        in.revision = revision;
        gApi.projects().name(project.getProject().getNameKey().get()).branch(name).create(in);
    } catch (RestApiException e) {
        throw die(e);
    }
}
Also used : BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) RestApiException(com.google.gerrit.extensions.restapi.RestApiException)

Aggregations

BranchInput (com.google.gerrit.extensions.api.projects.BranchInput)30 Test (org.junit.Test)21 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)18 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)17 CherryPickInput (com.google.gerrit.extensions.api.changes.CherryPickInput)11 RevCommit (org.eclipse.jgit.revwalk.RevCommit)8 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)7 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)4 ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)4 Branch (com.google.gerrit.reviewdb.client.Branch)4 BranchInfo (com.google.gerrit.extensions.api.projects.BranchInfo)3 RevisionInfo (com.google.gerrit.extensions.common.RevisionInfo)3 RefSpec (org.eclipse.jgit.transport.RefSpec)3 Before (org.junit.Before)3 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)2 Project (com.google.gerrit.reviewdb.client.Project)2 RefUpdate (org.eclipse.jgit.lib.RefUpdate)2 Repository (org.eclipse.jgit.lib.Repository)2 RevWalk (org.eclipse.jgit.revwalk.RevWalk)2 SubmitInput (com.google.gerrit.extensions.api.changes.SubmitInput)1