use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class AbstractSubmit method submitChangeWhenParentOfOtherBranchTip.
@Test
public void submitChangeWhenParentOfOtherBranchTip() throws Exception {
// Chain of two commits
// Push both to topic-branch
// Push the first commit for review and submit
//
// C2 -- tip of topic branch
// |
// C1 -- pushed for review
// |
// C0 -- Master
//
ProjectConfig config = projectCache.checkedGet(project).getConfig();
config.getProject().setCreateNewChangeForAllNotInTarget(InheritableBoolean.TRUE);
saveProjectConfig(project, config);
PushOneCommit push1 = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "a.txt", "content");
PushOneCommit.Result c1 = push1.to("refs/heads/topic");
c1.assertOkStatus();
PushOneCommit push2 = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent");
PushOneCommit.Result c2 = push2.to("refs/heads/topic");
c2.assertOkStatus();
PushOneCommit.Result change1 = push1.to("refs/for/master");
change1.assertOkStatus();
approve(change1.getChangeId());
submit(change1.getChangeId());
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class AbstractSubmit method submitMergeOfNonChangeBranchTip.
@Test
public void submitMergeOfNonChangeBranchTip() throws Exception {
// Merge a branch with commits that have not been submitted as
// changes.
//
// M -- mergeCommit (pushed for review and submitted)
// | \
// | S -- stable (pushed directly to refs/heads/stable)
// | /
// I -- master
//
RevCommit master = getRemoteHead(project, "master");
PushOneCommit stableTip = pushFactory.create(db, admin.getIdent(), testRepo, "Tip of branch stable", "stable.txt", "");
PushOneCommit.Result stable = stableTip.to("refs/heads/stable");
PushOneCommit mergeCommit = pushFactory.create(db, admin.getIdent(), testRepo, "The merge commit", "merge.txt", "");
mergeCommit.setParents(ImmutableList.of(master, stable.getCommit()));
PushOneCommit.Result mergeReview = mergeCommit.to("refs/for/master");
approve(mergeReview.getChangeId());
submit(mergeReview.getChangeId());
List<RevCommit> log = getRemoteLog();
assertThat(log).contains(stable.getCommit());
assertThat(log).contains(mergeReview.getCommit());
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class AbstractSubmitByMerge method submitMultipleCommitsToEmptyRepoWithOneMerge.
@Test
@TestProjectInput(createEmptyCommit = false)
public void submitMultipleCommitsToEmptyRepoWithOneMerge() throws Exception {
assume().that(isSubmitWholeTopicEnabled()).isTrue();
PushOneCommit.Result change1 = pushFactory.create(db, admin.getIdent(), testRepo, "Change 1", "a", "a").to("refs/for/master/" + name("topic"));
PushOneCommit push2 = pushFactory.create(db, admin.getIdent(), testRepo, "Change 2", "b", "b");
push2.noParents();
PushOneCommit.Result change2 = push2.to("refs/for/master/" + name("topic"));
change2.assertOkStatus();
approve(change1.getChangeId());
submit(change2.getChangeId());
RevCommit head = getRemoteHead();
assertThat(head.getParents()).hasLength(2);
assertThat(head.getParent(0)).isEqualTo(change1.getCommit());
assertThat(head.getParent(1)).isEqualTo(change2.getCommit());
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class AbstractSubmit method submitNoPermission.
@Test
public void submitNoPermission() throws Exception {
// create project where submit is blocked
Project.NameKey p = createProject("p");
block(p, "refs/*", Permission.SUBMIT, REGISTERED_USERS);
TestRepository<InMemoryRepository> repo = cloneProject(p, admin);
PushOneCommit push = pushFactory.create(db, admin.getIdent(), repo);
PushOneCommit.Result result = push.to("refs/for/master");
result.assertOkStatus();
submit(result.getChangeId(), new SubmitInput(), AuthException.class, "submit not permitted");
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class DeleteDraftPatchSetIT method deleteDraftPatchSetAndPushNewDraftPatchSet.
@Test
public void deleteDraftPatchSetAndPushNewDraftPatchSet() throws Exception {
String ref = "refs/drafts/master";
// Clone repository
TestRepository<InMemoryRepository> testRepo = cloneProject(project, admin);
// Create change
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
PushOneCommit.Result r1 = push.to(ref);
r1.assertOkStatus();
String revPs1 = r1.getChange().currentPatchSet().getRevision().get();
// Push draft patch set
PushOneCommit.Result r2 = amendChange(r1.getChangeId(), ref, admin, testRepo);
r2.assertOkStatus();
String revPs2 = r2.getChange().currentPatchSet().getRevision().get();
assertThat(gApi.changes().id(r1.getChange().getId().get()).get().currentRevision).isEqualTo(revPs2);
// Remove draft patch set
gApi.changes().id(r1.getChange().getId().get()).revision(revPs2).delete();
assertThat(gApi.changes().id(r1.getChange().getId().get()).get().currentRevision).isEqualTo(revPs1);
// Push new draft patch set
PushOneCommit.Result r3 = amendChange(r1.getChangeId(), ref, admin, testRepo);
r3.assertOkStatus();
String revPs3 = r2.getChange().currentPatchSet().getRevision().get();
assertThat(gApi.changes().id(r1.getChange().getId().get()).get().currentRevision).isEqualTo(revPs3);
// Check that all patch sets have different SHA1s
assertThat(revPs1).doesNotMatch(revPs2);
assertThat(revPs2).doesNotMatch(revPs3);
}
Aggregations