Search in sources :

Example 26 with RevisionInfo

use of com.google.gerrit.extensions.common.RevisionInfo in project gerrit by GerritCodeReview.

the class RevisionIT method cherryPickSetChangeId.

@Test
public void cherryPickSetChangeId() throws Exception {
    PushOneCommit.Result r = pushTo("refs/for/master");
    CherryPickInput in = new CherryPickInput();
    in.destination = "foo";
    String id = "Ideadbeefdeadbeefdeadbeefdeadbeefdeadbe3f";
    in.message = "it goes to foo branch\n\nChange-Id: " + id;
    gApi.projects().name(project.get()).branch(in.destination).create(new BranchInput());
    ChangeApi orig = gApi.changes().id(project.get() + "~master~" + r.getChangeId());
    assertThat(orig.get().messages).hasSize(1);
    ChangeApi cherry = orig.revision(r.getCommit().name()).cherryPick(in);
    ChangeInfo changeInfo = cherry.get();
    // The cherry-pick honors the ChangeId specified in the input message:
    RevisionInfo revInfo = changeInfo.revisions.get(changeInfo.currentRevision);
    // New change was created.
    assertThat(changeInfo._number).isGreaterThan(orig.get()._number);
    assertThat(changeInfo.changeId).isEqualTo(id);
    assertThat(revInfo).isNotNull();
    assertThat(revInfo.commit.message.trim()).endsWith(id);
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) ChangeApi(com.google.gerrit.extensions.api.changes.ChangeApi) CherryPickInput(com.google.gerrit.extensions.api.changes.CherryPickInput) BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 27 with RevisionInfo

use of com.google.gerrit.extensions.common.RevisionInfo in project gerrit by GerritCodeReview.

the class AbstractPushForReview method pushForMasterWithPercentEncodedMessage.

@Test
public void pushForMasterWithPercentEncodedMessage() throws Exception {
    // Exercise percent-encoding of UTF-8, underscores, and patterns reserved by git-rev-parse.
    PushOneCommit.Result r = pushTo("refs/for/master%m=" + "Punctu%2E%2e%2Eation%7E%2D%40%7Bu%7D%20%7C%20%28%E2%95%AF%C2%B0%E2%96%A1%C2%B0" + "%EF%BC%89%E2%95%AF%EF%B8%B5%20%E2%94%BB%E2%94%81%E2%94%BB%20%5E%5F%5E");
    r.assertOkStatus();
    r.assertChange(Change.Status.NEW, null);
    ChangeInfo ci = get(r.getChangeId(), MESSAGES, ALL_REVISIONS);
    Collection<ChangeMessageInfo> changeMessages = ci.messages;
    assertThat(changeMessages).hasSize(1);
    for (ChangeMessageInfo cm : changeMessages) {
        assertThat(cm.message).isEqualTo("Uploaded patch set 1.\nPunctu...ation~-@{u} | (╯°□°)╯︵ ┻━┻ ^_^");
    }
    Collection<RevisionInfo> revisions = ci.revisions.values();
    assertThat(revisions).hasSize(1);
    for (RevisionInfo ri : revisions) {
        assertThat(ri.description).isEqualTo("Punctu...ation~-@{u} | (╯°□°)╯︵ ┻━┻ ^_^");
    }
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 28 with RevisionInfo

use of com.google.gerrit.extensions.common.RevisionInfo in project gerrit by GerritCodeReview.

the class AbstractPushForReview method pushForMasterWithMessage.

@Test
public void pushForMasterWithMessage() throws Exception {
    PushOneCommit.Result r = pushTo("refs/for/master%m=my_test_message");
    r.assertOkStatus();
    r.assertChange(Change.Status.NEW, null);
    ChangeInfo ci = get(r.getChangeId(), MESSAGES, ALL_REVISIONS);
    Collection<ChangeMessageInfo> changeMessages = ci.messages;
    assertThat(changeMessages).hasSize(1);
    for (ChangeMessageInfo cm : changeMessages) {
        assertThat(cm.message).isEqualTo("Uploaded patch set 1.\nmy test message");
    }
    Collection<RevisionInfo> revisions = ci.revisions.values();
    assertThat(revisions).hasSize(1);
    for (RevisionInfo ri : revisions) {
        assertThat(ri.description).isEqualTo("my test message");
    }
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) ChangeMessageInfo(com.google.gerrit.extensions.common.ChangeMessageInfo) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 29 with RevisionInfo

use of com.google.gerrit.extensions.common.RevisionInfo in project gerrit by GerritCodeReview.

the class ChangeIT method rebaseFromRelationChainToClosedChange.

@Test
public void rebaseFromRelationChainToClosedChange() throws Exception {
    PushOneCommit.Result r1 = createChange();
    testRepo.reset("HEAD~1");
    createChange();
    PushOneCommit.Result r3 = createChange();
    // Submit first change.
    Change.Id id1 = r1.getChange().getId();
    gApi.changes().id(id1.get()).current().review(ReviewInput.approve());
    gApi.changes().id(id1.get()).current().submit();
    // Rebase third change on first change.
    RebaseInput in = new RebaseInput();
    in.base = id1.toString();
    gApi.changes().id(r3.getChangeId()).rebase(in);
    Change.Id id3 = r3.getChange().getId();
    ChangeInfo ci3 = get(r3.getChangeId(), CURRENT_REVISION, CURRENT_COMMIT);
    RevisionInfo ri3 = ci3.revisions.get(ci3.currentRevision);
    assertThat(ri3.commit.parents.get(0).commit).isEqualTo(r1.getCommit().name());
    assertThat(gApi.changes().id(id3.get()).revision(ri3._number).related().changes).isEmpty();
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) Change(com.google.gerrit.entities.Change) RebaseInput(com.google.gerrit.extensions.api.changes.RebaseInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 30 with RevisionInfo

use of com.google.gerrit.extensions.common.RevisionInfo in project gerrit by GerritCodeReview.

the class ChangeIT method rebaseOnClosedChange.

@Test
public void rebaseOnClosedChange() throws Exception {
    String branchTip = testRepo.getRepository().exactRef("HEAD").getObjectId().name();
    PushOneCommit.Result r1 = createChange();
    testRepo.reset("HEAD~1");
    PushOneCommit.Result r2 = createChange();
    ChangeInfo ci2 = get(r2.getChangeId(), CURRENT_REVISION, CURRENT_COMMIT);
    RevisionInfo ri2 = ci2.revisions.get(ci2.currentRevision);
    assertThat(ri2.commit.parents.get(0).commit).isEqualTo(branchTip);
    // Submit first change.
    Change.Id id1 = r1.getChange().getId();
    gApi.changes().id(id1.get()).current().review(ReviewInput.approve());
    gApi.changes().id(id1.get()).current().submit();
    // Rebase second change on first change.
    RebaseInput in = new RebaseInput();
    in.base = id1.toString();
    gApi.changes().id(r2.getChangeId()).rebase(in);
    Change.Id id2 = r2.getChange().getId();
    ci2 = get(r2.getChangeId(), CURRENT_REVISION, CURRENT_COMMIT);
    ri2 = ci2.revisions.get(ci2.currentRevision);
    assertThat(ri2.commit.parents.get(0).commit).isEqualTo(r1.getCommit().name());
    assertThat(gApi.changes().id(id2.get()).revision(ri2._number).related().changes).isEmpty();
}
Also used : ChangeInfo(com.google.gerrit.extensions.common.ChangeInfo) RevisionInfo(com.google.gerrit.extensions.common.RevisionInfo) Change(com.google.gerrit.entities.Change) RebaseInput(com.google.gerrit.extensions.api.changes.RebaseInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

RevisionInfo (com.google.gerrit.extensions.common.RevisionInfo)39 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)30 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)29 Test (org.junit.Test)29 PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)17 RevCommit (org.eclipse.jgit.revwalk.RevCommit)13 CherryPickInput (com.google.gerrit.extensions.api.changes.CherryPickInput)10 ChangeMessageInfo (com.google.gerrit.extensions.common.ChangeMessageInfo)10 Change (com.google.gerrit.entities.Change)8 Result (com.google.gerrit.acceptance.PushOneCommit.Result)5 ActionVisitor (com.google.gerrit.extensions.api.changes.ActionVisitor)5 PatchSet (com.google.gerrit.entities.PatchSet)4 ActionInfo (com.google.gerrit.extensions.common.ActionInfo)4 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)3 RebaseInput (com.google.gerrit.extensions.api.changes.RebaseInput)3 BranchInput (com.google.gerrit.extensions.api.projects.BranchInput)3 ListChangesOption (com.google.gerrit.extensions.client.ListChangesOption)3 Change (com.google.gerrit.reviewdb.client.Change)3 ChangeData (com.google.gerrit.server.query.change.ChangeData)3 Repository (org.eclipse.jgit.lib.Repository)3