Search in sources :

Example 6 with TestProjectInput

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

the class AbstractSubmitByMerge 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 oldHead = getRemoteHead();
    testRepo.reset(initialHead);
    PushOneCommit.Result change2 = createChange("Change 2", "a.txt", "other content");
    submitWithConflict(change2.getChangeId(), "Failed to submit 1 change due to the following problems:\n" + "Change " + change2.getChange().getId() + ": " + "Change could not be merged due to a path conflict. " + "Please rebase the change locally " + "and upload the rebased commit for review.");
    assertThat(getRemoteHead()).isEqualTo(oldHead);
}
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 7 with TestProjectInput

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

the class AbstractSubmitByMerge method submitWithContentMerge.

@Test
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitWithContentMerge() throws Exception {
    PushOneCommit.Result change = createChange("Change 1", "a.txt", "aaa\nbbb\nccc\n");
    submit(change.getChangeId());
    PushOneCommit.Result change2 = createChange("Change 2", "a.txt", "aaa\nbbb\nccc\nddd\n");
    submit(change2.getChangeId());
    RevCommit oldHead = getRemoteHead();
    testRepo.reset(change.getCommit());
    PushOneCommit.Result change3 = createChange("Change 3", "a.txt", "bbb\nccc\n");
    submit(change3.getChangeId());
    RevCommit head = getRemoteHead();
    assertThat(head.getParentCount()).isEqualTo(2);
    assertThat(head.getParent(0)).isEqualTo(oldHead);
    assertThat(head.getParent(1)).isEqualTo(change3.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 8 with TestProjectInput

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

the class AbstractSubmit method submitToEmptyRepo.

@Test
@TestProjectInput(createEmptyCommit = false)
public void submitToEmptyRepo() throws Exception {
    RevCommit initialHead = getRemoteHead();
    PushOneCommit.Result change = createChange();
    Map<Branch.NameKey, ObjectId> actual = fetchFromSubmitPreview(change.getChangeId());
    RevCommit headAfterSubmitPreview = getRemoteHead();
    assertThat(headAfterSubmitPreview).isEqualTo(initialHead);
    assertThat(actual).hasSize(1);
    submit(change.getChangeId());
    assertThat(getRemoteHead().getId()).isEqualTo(change.getCommit());
    assertTrees(project, actual);
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) TestProjectInput(com.google.gerrit.acceptance.TestProjectInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 9 with TestProjectInput

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

the class AbstractSubmitByRebase method submitChainOneByOneManualRebase.

@Test
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitChainOneByOneManualRebase() throws Exception {
    RevCommit initialHead = getRemoteHead();
    PushOneCommit.Result change1 = createChange("subject 1", "fileName 1", "content 1");
    PushOneCommit.Result change2 = createChange("subject 2", "fileName 2", "content 2");
    // 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 change = createChange();
    submit(change.getChangeId());
    submit(change1.getChangeId());
    // Do manual rebase first.
    gApi.changes().id(change2.getChangeId()).current().rebase();
    submit(change2.getChangeId());
}
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 10 with TestProjectInput

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

the class ChangeIT method changeNoParentToOneParent.

@Test
@TestProjectInput(createEmptyCommit = false)
public void changeNoParentToOneParent() throws Exception {
    // create initial commit with no parent and push it as change, so that patch
    // set 1 has no parent
    RevCommit c = testRepo.commit().message("Initial commit").insertChangeId().create();
    String id = GitUtil.getChangeId(testRepo, c).get();
    testRepo.reset(c);
    PushResult pr = pushHead(testRepo, "refs/for/master", false);
    assertPushOk(pr, "refs/for/master");
    ChangeInfo change = gApi.changes().id(id).get();
    assertThat(change.revisions.get(change.currentRevision).commit.parents).isEmpty();
    // create another initial commit with no parent and push it directly into
    // the remote repository
    c = testRepo.amend(c.getId()).message("Initial Empty Commit").create();
    testRepo.reset(c);
    pr = pushHead(testRepo, "refs/heads/master", false);
    assertPushOk(pr, "refs/heads/master");
    // create a successor commit and push it as second patch set to the change,
    // so that patch set 2 has 1 parent
    RevCommit c2 = testRepo.commit().message("Initial commit").parent(c).insertChangeId(id.substring(1)).create();
    testRepo.reset(c2);
    pr = pushHead(testRepo, "refs/for/master", false);
    assertPushOk(pr, "refs/for/master");
    change = gApi.changes().id(id).get();
    RevisionInfo rev = change.revisions.get(change.currentRevision);
    assertThat(rev.commit.parents).hasSize(1);
    assertThat(rev.commit.parents.get(0).commit).isEqualTo(c.name());
    // check that change kind is correctly detected as REWORK
    assertThat(rev.kind).isEqualTo(ChangeKind.REWORK);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) PushResult(org.eclipse.jgit.transport.PushResult) RevCommit(org.eclipse.jgit.revwalk.RevCommit) TestProjectInput(com.google.gerrit.acceptance.TestProjectInput) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) 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