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);
}
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} | (╯°□°)╯︵ ┻━┻ ^_^");
}
}
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");
}
}
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();
}
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();
}
Aggregations