use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class DeleteDraftPatchSetIT method deleteCurrentDraftPatchSetWhenPreviousPatchSetDoesNotExist.
@Test
public void deleteCurrentDraftPatchSetWhenPreviousPatchSetDoesNotExist() throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
String changeId = push.to("refs/for/master").getChangeId();
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "foo", changeId).to("refs/drafts/master");
pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "bar", changeId).to("refs/drafts/master");
deletePatchSet(changeId, 2);
deletePatchSet(changeId, 3);
ChangeData cd = getChange(changeId);
assertThat(cd.patchSets()).hasSize(1);
assertThat(Iterables.getOnlyElement(cd.patchSets()).getId().get()).isEqualTo(1);
assertThat(cd.currentPatchSet().getId().get()).isEqualTo(1);
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class CreateChangeIT method changeInTwoBranches.
/**
* Create an empty commit in master, two new branches with one commit each.
*
* @param branchA name of first branch to create
* @param fileA name of file to commit to branchA
* @param branchB name of second branch to create
* @param fileB name of file to commit to branchB
* @return A {@code Map} of branchName => commit result.
* @throws Exception
*/
private Map<String, Result> changeInTwoBranches(String branchA, String fileA, String branchB, String fileB) throws Exception {
// create a initial commit in master
Result initialCommit = pushFactory.create(db, user.getIdent(), testRepo, "initial commit", "readme.txt", "initial commit").to("refs/heads/master");
initialCommit.assertOkStatus();
// create two new branches
createBranch(new Branch.NameKey(project, branchA));
createBranch(new Branch.NameKey(project, branchB));
// create a commit in branchA
Result changeA = pushFactory.create(db, user.getIdent(), testRepo, "change A", fileA, "A content").to("refs/heads/" + branchA);
changeA.assertOkStatus();
// create a commit in branchB
PushOneCommit commitB = pushFactory.create(db, user.getIdent(), testRepo, "change B", fileB, "B content");
commitB.setParent(initialCommit.getCommit());
Result changeB = commitB.to("refs/heads/" + branchB);
changeB.assertOkStatus();
return ImmutableMap.of("master", initialCommit, branchA, changeA, branchB, changeB);
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class MoveChangeIT method createChange.
private PushOneCommit.Result createChange(String branch, String changeId) throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, changeId);
PushOneCommit.Result result = push.to("refs/for/" + branch);
result.assertOkStatus();
return result;
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class SubmitResolvingMergeCommitIT method createChange.
private PushOneCommit.Result createChange(TestRepository<?> repo, String subject, String fileName, String content, List<RevCommit> parents, String ref) throws Exception {
PushOneCommit push = pushFactory.create(db, admin.getIdent(), repo, subject, fileName, content);
if (!parents.isEmpty()) {
push.setParents(parents);
}
PushOneCommit.Result result;
if (fileName.isEmpty()) {
result = push.execute(ref);
} else {
result = push.to(ref);
}
result.assertOkStatus();
return result;
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class SubmitByMergeIfNecessaryIT method openChangeForTargetBranchPreventsMerge.
@Test
public void openChangeForTargetBranchPreventsMerge() throws Exception {
gApi.projects().name(project.get()).branch("stable").create(new BranchInput());
// Propose a change for master, but leave it open for master!
PushOneCommit change = pushFactory.create(db, user.getIdent(), testRepo, "small fix", "a.txt", "2");
PushOneCommit.Result change2result = change.to("refs/for/master");
// Now cherry pick to stable
CherryPickInput in = new CherryPickInput();
in.destination = "stable";
in.message = "it goes to stable branch";
ChangeApi orig = gApi.changes().id(change2result.getChangeId());
ChangeApi cherry = orig.current().cherryPick(in);
cherry.current().review(ReviewInput.approve());
cherry.current().submit();
// Create a commit locally
testRepo.git().fetch().setRefSpecs(new RefSpec("refs/heads/stable")).call();
PushOneCommit.Result change3 = createChange(testRepo, "stable", "test", "a.txt", "3", "");
submitWithConflict(change3.getChangeId(), "Failed to submit 1 change due to the following problems:\n" + "Change " + change3.getPatchSetId().getParentKey().get() + ": depends on change that was not submitted");
assertRefUpdatedEvents();
assertChangeMergedEvents();
}
Aggregations