use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevisionIT method cherryPickOnMergedChangeIsNotRelated.
@Test
public void cherryPickOnMergedChangeIsNotRelated() throws Exception {
PushOneCommit.Result r1 = createChange(SUBJECT, "a.txt", "a");
PushOneCommit.Result r2 = createChange(SUBJECT, "b.txt", "b");
String branch = "foo";
// Create target branch to cherry-pick to.
gApi.projects().name(project.get()).branch(branch).create(new BranchInput());
CherryPickInput input = new CherryPickInput();
input.message = "message";
input.destination = branch;
ChangeInfo firstCherryPickResult = gApi.changes().id(r1.getChangeId()).current().cherryPickAsInfo(input);
gApi.changes().id(firstCherryPickResult.id).current().review(ReviewInput.approve());
gApi.changes().id(firstCherryPickResult.id).current().submit();
input.base = gApi.changes().id(firstCherryPickResult.changeId).current().commit(false).commit;
ChangeInfo secondCherryPickResult = gApi.changes().id(r2.getChangeId()).current().cherryPickAsInfo(input);
assertThat(gApi.changes().id(firstCherryPickResult.changeId).current().related().changes).hasSize(0);
assertThat(gApi.changes().id(secondCherryPickResult.changeId).current().related().changes).hasSize(0);
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevisionIT method submit.
@Test
public void submit() throws Exception {
PushOneCommit.Result r = createChange();
String changeId = project.get() + "~master~" + r.getChangeId();
gApi.changes().id(changeId).current().review(ReviewInput.approve());
ChangeInfo changeInfo = gApi.changes().id(changeId).current().submit();
assertThat(changeInfo.status).isEqualTo(ChangeStatus.MERGED);
assertThat(gApi.changes().id(changeId).get().status).isEqualTo(ChangeStatus.MERGED);
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class RevisionIT method getApproval.
private ApprovalInfo getApproval(String changeId, String label) throws Exception {
ChangeInfo info = gApi.changes().id(changeId).get(DETAILED_LABELS);
LabelInfo li = info.labels.get(label);
assertThat(li).isNotNull();
int accountId = atrScope.get().getUser().getAccountId().get();
return li.all.stream().filter(a -> a._accountId == accountId).findFirst().get();
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class ChangeEditIT method updateMessage.
@Test
public void updateMessage() throws Exception {
createEmptyEditFor(changeId);
String msg = String.format("New commit message\n\nChange-Id: %s\n", changeId);
gApi.changes().id(changeId).edit().modifyCommitMessage(msg);
String commitMessage = gApi.changes().id(changeId).edit().getCommitMessage();
assertThat(commitMessage).isEqualTo(msg);
PublishChangeEditInput publishInput = new PublishChangeEditInput();
publishInput.notify = NotifyHandling.NONE;
gApi.changes().id(changeId).edit().publish(publishInput);
assertThat(getEdit(changeId)).isAbsent();
ChangeInfo info = get(changeId, ListChangesOption.CURRENT_COMMIT, ListChangesOption.CURRENT_REVISION);
assertThat(info.revisions.get(info.currentRevision).commit.message).isEqualTo(msg);
assertThat(info.revisions.get(info.currentRevision).description).isEqualTo("Edit commit message");
assertChangeMessages(changeId, ImmutableList.of("Uploaded patch set 1.", "Uploaded patch set 2.", "Patch Set 3: Commit message was updated."));
}
use of com.google.gerrit.extensions.common.ChangeInfo in project gerrit by GerritCodeReview.
the class ChangeEditIT method publishEdit.
@Test
public void publishEdit() throws Exception {
createArbitraryEditFor(changeId);
ReviewerInput in = new ReviewerInput();
in.reviewer = user.email();
gApi.changes().id(changeId).addReviewer(in);
PublishChangeEditInput publishInput = new PublishChangeEditInput();
gApi.changes().id(changeId).edit().publish(publishInput);
assertThat(getEdit(changeId)).isAbsent();
assertChangeMessages(changeId, ImmutableList.of("Uploaded patch set 1.", "Uploaded patch set 2.", "Patch Set 3: Published edit on patch set 2."));
// The tag for the publish edit change message should vary according
// to whether the change was WIP at the time of publishing.
ChangeInfo info = get(changeId, MESSAGES);
assertThat(info.messages).isNotEmpty();
assertThat(Iterables.getLast(info.messages).tag).isEqualTo(ChangeMessagesUtil.TAG_UPLOADED_PATCH_SET);
assertThat(sender.getMessages()).isNotEmpty();
// Move the change to WIP, repeat, and verify.
sender.clear();
gApi.changes().id(changeId).setWorkInProgress();
createEmptyEditFor(changeId);
gApi.changes().id(changeId).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW2));
gApi.changes().id(changeId).edit().publish();
info = get(changeId, MESSAGES);
assertThat(info.messages).isNotEmpty();
assertThat(Iterables.getLast(info.messages).tag).isEqualTo(ChangeMessagesUtil.TAG_UPLOADED_WIP_PATCH_SET);
assertThat(sender.getMessages()).isEmpty();
}
Aggregations