use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushForMasterWithMessageTwiceWithDifferentMessages.
@Test
public void pushForMasterWithMessageTwiceWithDifferentMessages() throws Exception {
enableCreateNewChangeForAllNotInTarget();
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "a.txt", "content");
PushOneCommit.Result r = push.to("refs/for/master/%m=my_test_message");
r.assertOkStatus();
push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent", r.getChangeId());
r = push.to("refs/for/master/%m=new_test_message");
r.assertOkStatus();
ChangeInfo ci = get(r.getChangeId());
Collection<RevisionInfo> revisions = ci.revisions.values();
assertThat(revisions).hasSize(2);
for (RevisionInfo ri : revisions) {
if (ri.isCurrent) {
assertThat(ri.description).isEqualTo("new test message");
} else {
assertThat(ri.description).isEqualTo("my test message");
}
}
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushCommitWithSameChangeIdAsPredecessorChange.
@Test
public void pushCommitWithSameChangeIdAsPredecessorChange() throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "a.txt", "content");
PushOneCommit.Result r = push.to("refs/for/master");
r.assertOkStatus();
RevCommit commitChange1 = r.getCommit();
createCommit(testRepo, commitChange1.getFullMessage());
pushForReviewRejected(testRepo, "same Change-Id in multiple changes.\n" + "Squash the commits with the same Change-Id or ensure Change-Ids are unique for each" + " commit");
ProjectConfig config = projectCache.checkedGet(project).getConfig();
config.getProject().setRequireChangeID(InheritableBoolean.FALSE);
saveProjectConfig(project, config);
pushForReviewRejected(testRepo, "same Change-Id in multiple changes.\n" + "Squash the commits with the same Change-Id or ensure Change-Ids are unique for each" + " commit");
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class SubmitOnPushIT method mergeOnPushToBranchWithNewPatchset.
@Test
public void mergeOnPushToBranchWithNewPatchset() throws Exception {
grant(project, "refs/heads/master", Permission.PUSH);
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
RevCommit c1 = r.getCommit();
PatchSet.Id psId1 = r.getPatchSetId();
assertThat(psId1.get()).isEqualTo(1);
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent", r.getChangeId());
r = push.to("refs/heads/master");
r.assertOkStatus();
ChangeData cd = r.getChange();
RevCommit c2 = r.getCommit();
assertThat(cd.change().getStatus()).isEqualTo(Change.Status.MERGED);
PatchSet.Id psId2 = cd.change().currentPatchSetId();
assertThat(psId2.get()).isEqualTo(2);
assertCommit(project, "refs/heads/master");
assertSubmitApproval(psId2);
assertThat(cd.patchSets()).hasSize(2);
assertThat(cd.patchSet(psId1).getRevision().get()).isEqualTo(c1.name());
assertThat(cd.patchSet(psId2).getRevision().get()).isEqualTo(c2.name());
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class SubmitOnPushIT method submitOnPushWithAnnotatedTag.
@Test
public void submitOnPushWithAnnotatedTag() throws Exception {
grant(project, "refs/for/refs/heads/master", Permission.SUBMIT);
grant(project, "refs/tags/*", Permission.PUSH);
PushOneCommit.AnnotatedTag tag = new PushOneCommit.AnnotatedTag("v1.0", "annotation", admin.getIdent());
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
push.setTag(tag);
PushOneCommit.Result r = push.to("refs/for/master%submit");
r.assertOkStatus();
r.assertChange(Change.Status.MERGED, null, admin);
assertSubmitApproval(r.getPatchSetId());
assertCommit(project, "refs/heads/master");
assertTag(project, "refs/heads/master", tag);
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushForMasterWithApprovals.
@Test
public void pushForMasterWithApprovals() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master/%l=Code-Review");
r.assertOkStatus();
ChangeInfo ci = get(r.getChangeId());
LabelInfo cr = ci.labels.get("Code-Review");
assertThat(cr.all).hasSize(1);
assertThat(cr.all.get(0).name).isEqualTo("Administrator");
assertThat(cr.all.get(0).value).isEqualTo(1);
assertThat(Iterables.getLast(ci.messages).message).isEqualTo("Uploaded patch set 1: Code-Review+1.");
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent", r.getChangeId());
r = push.to("refs/for/master/%l=Code-Review+2");
ci = get(r.getChangeId());
cr = ci.labels.get("Code-Review");
assertThat(Iterables.getLast(ci.messages).message).isEqualTo("Uploaded patch set 2: Code-Review+2.");
// Check that the user who pushed the change was added as a reviewer since they added a vote
assertThatUserIsOnlyReviewer(ci, admin);
assertThat(cr.all).hasSize(1);
assertThat(cr.all.get(0).name).isEqualTo("Administrator");
assertThat(cr.all.get(0).value).isEqualTo(2);
push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "c.txt", "moreContent", r.getChangeId());
r = push.to("refs/for/master/%l=Code-Review+2");
ci = get(r.getChangeId());
assertThat(Iterables.getLast(ci.messages).message).isEqualTo("Uploaded patch set 3.");
}
Aggregations