Search in sources :

Example 16 with TestProjectInput

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

the class AbstractSubmitByRebase method submitWithRebaseWithoutAddPatchSetPermission.

@Test
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitWithRebaseWithoutAddPatchSetPermission() throws Exception {
    ProjectConfig cfg = projectCache.checkedGet(project).getConfig();
    Util.block(cfg, Permission.ADD_PATCH_SET, REGISTERED_USERS, "refs/*");
    Util.allow(cfg, Permission.SUBMIT, REGISTERED_USERS, "refs/heads/*");
    Util.allow(cfg, Permission.forLabel(Util.codeReview().getName()), -2, 2, REGISTERED_USERS, "refs/heads/*");
    saveProjectConfig(project, cfg);
    submitWithRebase(user);
}
Also used : ProjectConfig(com.google.gerrit.server.git.ProjectConfig) TestProjectInput(com.google.gerrit.acceptance.TestProjectInput) Test(org.junit.Test)

Example 17 with TestProjectInput

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

the class SubmitByCherryPickIT method submitIdenticalTree.

@Test
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitIdenticalTree() throws Exception {
    RevCommit initialHead = getRemoteHead();
    PushOneCommit.Result change1 = createChange("Change 1", "a.txt", "a");
    testRepo.reset(initialHead);
    PushOneCommit.Result change2 = createChange("Change 2", "a.txt", "a");
    submit(change1.getChangeId());
    RevCommit headAfterFirstSubmit = getRemoteHead();
    assertThat(headAfterFirstSubmit.getShortMessage()).isEqualTo("Change 1");
    submit(change2.getChangeId(), new SubmitInput(), null, null);
    assertThat(getRemoteHead()).isEqualTo(headAfterFirstSubmit);
    ChangeInfo info2 = get(change2.getChangeId());
    assertThat(info2.status).isEqualTo(ChangeStatus.MERGED);
    assertThat(Iterables.getLast(info2.messages).message).isEqualTo(CommitMergeStatus.SKIPPED_IDENTICAL_TREE.getMessage());
    assertRefUpdatedEvents(initialHead, headAfterFirstSubmit);
    assertChangeMergedEvents(change1.getChangeId(), headAfterFirstSubmit.name(), change2.getChangeId(), headAfterFirstSubmit.name());
}
Also used : SubmitInput(com.google.gerrit.extensions.api.changes.SubmitInput) TestSubmitInput(com.google.gerrit.server.change.Submit.TestSubmitInput) 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 18 with TestProjectInput

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

the class SubmitByCherryPickIT 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 newHead = 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(newHead);
    assertCurrentRevision(change2.getChangeId(), 1, change2.getCommit());
    assertNoSubmitter(change2.getChangeId(), 1);
    assertRefUpdatedEvents(initialHead, newHead);
    assertChangeMergedEvents(change.getChangeId(), newHead.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 19 with TestProjectInput

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

the class SubmitByRebaseIfNecessaryIT method submitWithContentMerge.

@Test
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitWithContentMerge() throws Exception {
    RevCommit initialHead = getRemoteHead();
    PushOneCommit.Result change = createChange("Change 1", "a.txt", "aaa\nbbb\nccc\n");
    submit(change.getChangeId());
    RevCommit headAfterFirstSubmit = getRemoteHead();
    PushOneCommit.Result change2 = createChange("Change 2", "a.txt", "aaa\nbbb\nccc\nddd\n");
    submit(change2.getChangeId());
    RevCommit headAfterSecondSubmit = getRemoteHead();
    testRepo.reset(change.getCommit());
    PushOneCommit.Result change3 = createChange("Change 3", "a.txt", "bbb\nccc\n");
    submit(change3.getChangeId());
    assertRebase(testRepo, true);
    RevCommit headAfterThirdSubmit = getRemoteHead();
    assertThat(headAfterThirdSubmit.getParent(0)).isEqualTo(headAfterSecondSubmit);
    assertApproved(change3.getChangeId());
    assertCurrentRevision(change3.getChangeId(), 2, headAfterThirdSubmit);
    assertSubmitter(change3.getChangeId(), 1);
    assertSubmitter(change3.getChangeId(), 2);
    assertRefUpdatedEvents(initialHead, headAfterFirstSubmit, headAfterFirstSubmit, headAfterSecondSubmit, headAfterSecondSubmit, headAfterThirdSubmit);
    assertChangeMergedEvents(change.getChangeId(), headAfterFirstSubmit.name(), change2.getChangeId(), headAfterSecondSubmit.name(), change3.getChangeId(), headAfterThirdSubmit.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 20 with TestProjectInput

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

the class SubmitByCherryPickIT method submitWithContentMerge.

@Test
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitWithContentMerge() throws Exception {
    RevCommit initialHead = getRemoteHead();
    PushOneCommit.Result change = createChange("Change 1", "a.txt", "aaa\nbbb\nccc\n");
    submit(change.getChangeId());
    RevCommit headAfterFirstSubmit = getRemoteHead();
    PushOneCommit.Result change2 = createChange("Change 2", "a.txt", "aaa\nbbb\nccc\nddd\n");
    submit(change2.getChangeId());
    RevCommit headAfterSecondSubmit = getRemoteHead();
    testRepo.reset(change.getCommit());
    PushOneCommit.Result change3 = createChange("Change 3", "a.txt", "bbb\nccc\n");
    submit(change3.getChangeId());
    assertCherryPick(testRepo, true);
    RevCommit headAfterThirdSubmit = getRemoteHead();
    assertThat(headAfterThirdSubmit.getParent(0)).isEqualTo(headAfterSecondSubmit);
    assertApproved(change3.getChangeId());
    assertCurrentRevision(change3.getChangeId(), 2, headAfterThirdSubmit);
    assertSubmitter(change2.getChangeId(), 1);
    assertSubmitter(change2.getChangeId(), 2);
    assertRefUpdatedEvents(initialHead, headAfterFirstSubmit, headAfterFirstSubmit, headAfterSecondSubmit, headAfterSecondSubmit, headAfterThirdSubmit);
    assertChangeMergedEvents(change.getChangeId(), headAfterFirstSubmit.name(), change2.getChangeId(), headAfterSecondSubmit.name(), change3.getChangeId(), headAfterThirdSubmit.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)

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