Search in sources :

Example 21 with TestProjectInput

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

the class SubmitByRebaseAlwaysIT method submitWithPossibleFastForward.

@Test
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void submitWithPossibleFastForward() throws Exception {
    RevCommit oldHead = getRemoteHead();
    PushOneCommit.Result change = createChange();
    submit(change.getChangeId());
    RevCommit head = getRemoteHead();
    assertThat(head.getId()).isNotEqualTo(change.getCommit());
    assertThat(head.getParent(0)).isEqualTo(oldHead);
    assertApproved(change.getChangeId());
    assertCurrentRevision(change.getChangeId(), 2, head);
    assertSubmitter(change.getChangeId(), 1);
    assertSubmitter(change.getChangeId(), 2);
    assertPersonEquals(admin.getIdent(), head.getAuthorIdent());
    assertPersonEquals(admin.getIdent(), head.getCommitterIdent());
    assertRefUpdatedEvents(oldHead, head);
    assertChangeMergedEvents(change.getChangeId(), head.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 22 with TestProjectInput

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

the class SubmitByRebaseAlwaysIT method changeMessageOnSubmit.

@Test
@TestProjectInput(useContentMerge = InheritableBoolean.TRUE)
public void changeMessageOnSubmit() throws Exception {
    PushOneCommit.Result change1 = createChange();
    PushOneCommit.Result change2 = createChange();
    RegistrationHandle handle = changeMessageModifiers.add(new ChangeMessageModifier() {

        @Override
        public String onSubmit(String newCommitMessage, RevCommit original, RevCommit mergeTip, Branch.NameKey destination) {
            List<String> custom = mergeTip.getFooterLines("Custom");
            if (!custom.isEmpty()) {
                newCommitMessage += "Custom-Parent: " + custom.get(0) + "\n";
            }
            return newCommitMessage + "Custom: " + destination.get();
        }
    });
    try {
        // change1 is a fast-forward, but should be rebased in cherry pick style
        // anyway, making change2 not a fast-forward, requiring a rebase.
        approve(change1.getChangeId());
        submit(change2.getChangeId());
    } finally {
        handle.remove();
    }
    // ... but both changes should get custom footers.
    assertThat(getCurrentCommit(change1).getFooterLines("Custom")).containsExactly("refs/heads/master");
    assertThat(getCurrentCommit(change2).getFooterLines("Custom")).containsExactly("refs/heads/master");
    assertThat(getCurrentCommit(change2).getFooterLines("Custom-Parent")).containsExactly("refs/heads/master");
}
Also used : RegistrationHandle(com.google.gerrit.extensions.registration.RegistrationHandle) Branch(com.google.gerrit.reviewdb.client.Branch) List(java.util.List) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) ChangeMessageModifier(com.google.gerrit.server.git.ChangeMessageModifier) 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