Search in sources :

Example 11 with TestProjectInput

use of com.google.gerrit.acceptance.TestProjectInput in project gerrit by GerritCodeReview.

the class RevisionIT method approvalCopiedDuringSubmitIsNotPostSubmit.

@TestProjectInput(submitType = SubmitType.CHERRY_PICK)
@Test
public void approvalCopiedDuringSubmitIsNotPostSubmit() throws Exception {
    PushOneCommit.Result r = createChange();
    Change.Id id = r.getChange().getId();
    gApi.changes().id(id.get()).current().review(ReviewInput.approve());
    gApi.changes().id(id.get()).current().submit();
    ChangeData cd = r.getChange();
    assertThat(cd.patchSets()).hasSize(2);
    PatchSetApproval psa = Iterators.getOnlyElement(cd.currentApprovals().stream().filter(a -> !a.isLegacySubmit()).iterator());
    assertThat(psa.getPatchSetId().get()).isEqualTo(2);
    assertThat(psa.getLabel()).isEqualTo("Code-Review");
    assertThat(psa.getValue()).isEqualTo(2);
    assertThat(psa.isPostSubmit()).isFalse();
}
Also used : Change(com.google.gerrit.reviewdb.client.Change) ChangeData(com.google.gerrit.server.query.change.ChangeData) PatchSetApproval(com.google.gerrit.reviewdb.client.PatchSetApproval) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) TestProjectInput(com.google.gerrit.acceptance.TestProjectInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 12 with TestProjectInput

use of com.google.gerrit.acceptance.TestProjectInput in project gerrit by GerritCodeReview.

the class AbstractSubmitByMerge method submitMultipleCommitsToEmptyRepoWithOneMerge.

@Test
@TestProjectInput(createEmptyCommit = false)
public void submitMultipleCommitsToEmptyRepoWithOneMerge() throws Exception {
    assume().that(isSubmitWholeTopicEnabled()).isTrue();
    PushOneCommit.Result change1 = pushFactory.create(db, admin.getIdent(), testRepo, "Change 1", "a", "a").to("refs/for/master/" + name("topic"));
    PushOneCommit push2 = pushFactory.create(db, admin.getIdent(), testRepo, "Change 2", "b", "b");
    push2.noParents();
    PushOneCommit.Result change2 = push2.to("refs/for/master/" + name("topic"));
    change2.assertOkStatus();
    approve(change1.getChangeId());
    submit(change2.getChangeId());
    RevCommit head = getRemoteHead();
    assertThat(head.getParents()).hasLength(2);
    assertThat(head.getParent(0)).isEqualTo(change1.getCommit());
    assertThat(head.getParent(1)).isEqualTo(change2.getCommit());
}
Also used : PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) TestProjectInput(com.google.gerrit.acceptance.TestProjectInput) Test(org.junit.Test)

Example 13 with TestProjectInput

use of com.google.gerrit.acceptance.TestProjectInput in project gerrit by GerritCodeReview.

the class AbstractSubmitByRebase method submitFastForwardIdenticalTree.

@Test
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitFastForwardIdenticalTree() throws Exception {
    RevCommit initialHead = getRemoteHead();
    PushOneCommit.Result change1 = createChange("Change 1", "a.txt", "a");
    PushOneCommit.Result change2 = createChange("Change 2", "a.txt", "a");
    assertThat(change1.getCommit().getTree()).isEqualTo(change2.getCommit().getTree());
    // for rebase if necessary, otherwise, the manual rebase of change2 will
    // fail since change1 would be merged as fast forward
    testRepo.reset(initialHead);
    PushOneCommit.Result change0 = createChange("Change 0", "b.txt", "b");
    submit(change0.getChangeId());
    RevCommit headAfterChange0 = getRemoteHead();
    assertThat(headAfterChange0.getShortMessage()).isEqualTo("Change 0");
    submit(change1.getChangeId());
    RevCommit headAfterChange1 = getRemoteHead();
    assertThat(headAfterChange1.getShortMessage()).isEqualTo("Change 1");
    assertThat(headAfterChange0).isEqualTo(headAfterChange1.getParent(0));
    // Do manual rebase first.
    gApi.changes().id(change2.getChangeId()).current().rebase();
    submit(change2.getChangeId());
    RevCommit headAfterChange2 = getRemoteHead();
    assertThat(headAfterChange2.getShortMessage()).isEqualTo("Change 2");
    assertThat(headAfterChange1).isEqualTo(headAfterChange2.getParent(0));
    ChangeInfo info2 = get(change2.getChangeId());
    assertThat(info2.status).isEqualTo(ChangeStatus.MERGED);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) TestProjectInput(com.google.gerrit.acceptance.TestProjectInput) Test(org.junit.Test)

Example 14 with TestProjectInput

use of com.google.gerrit.acceptance.TestProjectInput in project gerrit by GerritCodeReview.

the class AbstractSubmitByRebase method submitWithContentMerge_Conflict.

@Test
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitWithContentMerge_Conflict() throws Exception {
    RevCommit initialHead = getRemoteHead();
    PushOneCommit.Result change = createChange("Change 1", "a.txt", "content");
    submit(change.getChangeId());
    RevCommit headAfterFirstSubmit = getRemoteHead();
    testRepo.reset(initialHead);
    PushOneCommit.Result change2 = createChange("Change 2", "a.txt", "other content");
    submitWithConflict(change2.getChangeId(), "Cannot rebase " + change2.getCommit().name() + ": The change could not be rebased due to a conflict during merge.");
    RevCommit head = getRemoteHead();
    assertThat(head).isEqualTo(headAfterFirstSubmit);
    assertCurrentRevision(change2.getChangeId(), 1, change2.getCommit());
    assertNoSubmitter(change2.getChangeId(), 1);
    assertRefUpdatedEvents(initialHead, headAfterFirstSubmit);
    assertChangeMergedEvents(change.getChangeId(), headAfterFirstSubmit.name());
}
Also used : PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) TestProjectInput(com.google.gerrit.acceptance.TestProjectInput) Test(org.junit.Test)

Example 15 with TestProjectInput

use of com.google.gerrit.acceptance.TestProjectInput in project gerrit by GerritCodeReview.

the class AbstractSubmitByRebase method submitChainFailsOnRework.

@Test
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitChainFailsOnRework() throws Exception {
    PushOneCommit.Result change1 = createChange("subject 1", "fileName 1", "content 1");
    RevCommit headAfterChange1 = change1.getCommit();
    PushOneCommit.Result change2 = createChange("subject 2", "fileName 2", "content 2");
    testRepo.reset(headAfterChange1);
    change1 = amendChange(change1.getChangeId(), "subject 1 amend", "fileName 2", "rework content 2");
    submit(change1.getChangeId());
    headAfterChange1 = getRemoteHead();
    submitWithConflict(change2.getChangeId(), "Cannot rebase " + change2.getCommit().getName() + ": " + "The change could not be rebased due to a conflict during merge.");
    assertThat(getRemoteHead()).isEqualTo(headAfterChange1);
}
Also used : PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) TestProjectInput(com.google.gerrit.acceptance.TestProjectInput) Test(org.junit.Test)

Aggregations

TestProjectInput (com.google.gerrit.acceptance.TestProjectInput)22 Test (org.junit.Test)22 RevCommit (org.eclipse.jgit.revwalk.RevCommit)19 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)18 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)7 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)4 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)2 PushResult (org.eclipse.jgit.transport.PushResult)2 SubmitInput (com.google.gerrit.extensions.api.changes.SubmitInput)1 ProjectInput (com.google.gerrit.extensions.api.projects.ProjectInput)1 RevisionInfo (com.google.gerrit.extensions.common.RevisionInfo)1 RegistrationHandle (com.google.gerrit.extensions.registration.RegistrationHandle)1 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)1 Branch (com.google.gerrit.reviewdb.client.Branch)1 Change (com.google.gerrit.reviewdb.client.Change)1 LabelId (com.google.gerrit.reviewdb.client.LabelId)1 PatchSetApproval (com.google.gerrit.reviewdb.client.PatchSetApproval)1 TestSubmitInput (com.google.gerrit.server.change.Submit.TestSubmitInput)1 ChangeMessageModifier (com.google.gerrit.server.git.ChangeMessageModifier)1 ChangeData (com.google.gerrit.server.query.change.ChangeData)1