use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class ChangeEditIT method rebaseEditWithConflictsRest_Conflict.
@Test
public void rebaseEditWithConflictsRest_Conflict() throws Exception {
PatchSet currentPatchSet = getCurrentPatchSet(changeId2);
createEmptyEditFor(changeId2);
gApi.changes().id(changeId2).edit().modifyFile(FILE_NAME, RawInputUtil.create(CONTENT_NEW));
Optional<EditInfo> edit = getEdit(changeId2);
assertThat(edit).value().baseRevision().isEqualTo(currentPatchSet.getRevision().get());
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, FILE_NAME, new String(CONTENT_NEW2, UTF_8), changeId2);
push.to("refs/for/master").assertOkStatus();
adminRestSession.post(urlRebase(changeId2)).assertConflict();
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class AbstractPushForReview method pushNewPatchsetToRefsChanges.
@Test
public void pushNewPatchsetToRefsChanges() throws Exception {
PushOneCommit.Result r = pushTo("refs/for/master");
r.assertOkStatus();
PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent", r.getChangeId());
r = push.to("refs/changes/" + r.getChange().change().getId().get());
r.assertOkStatus();
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class ChangeIT method createNewPatchSetAsReviewerOnDraftChange.
@Test
public void createNewPatchSetAsReviewerOnDraftChange() throws Exception {
// Clone separate repositories of the same project as admin and as user
TestRepository<?> adminTestRepo = cloneProject(project, admin);
TestRepository<?> userTestRepo = cloneProject(project, user);
// Create change as admin
PushOneCommit push = pushFactory.create(db, admin.getIdent(), adminTestRepo);
PushOneCommit.Result r1 = push.to("refs/drafts/master");
r1.assertOkStatus();
// Add user as reviewer
AddReviewerInput in = new AddReviewerInput();
in.reviewer = user.email;
gApi.changes().id(r1.getChangeId()).addReviewer(in);
// Fetch change
GitUtil.fetch(userTestRepo, r1.getPatchSet().getRefName() + ":ps");
userTestRepo.reset("ps");
// Amend change as user
PushOneCommit.Result r2 = amendChange(r1.getChangeId(), "refs/for/master", user, userTestRepo);
r2.assertOkStatus();
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class ChangeIT method createNewDraftPatchSetOnDraftChange.
@Test
public void createNewDraftPatchSetOnDraftChange() throws Exception {
// Create new project with clean permissions
Project.NameKey p = createProject("addPatchSet4");
// Clone separate repositories of the same project as admin and as user
TestRepository<?> adminTestRepo = cloneProject(p, admin);
TestRepository<?> userTestRepo = cloneProject(p, user);
// Block default permission
block(p, "refs/for/*", Permission.ADD_PATCH_SET, REGISTERED_USERS);
// Create change as admin
PushOneCommit push = pushFactory.create(db, admin.getIdent(), adminTestRepo);
PushOneCommit.Result r1 = push.to("refs/drafts/master");
r1.assertOkStatus();
// Add user as reviewer
AddReviewerInput in = new AddReviewerInput();
in.reviewer = user.email;
gApi.changes().id(r1.getChangeId()).addReviewer(in);
// Fetch change
GitUtil.fetch(userTestRepo, r1.getPatchSet().getRefName() + ":ps");
userTestRepo.reset("ps");
// Amend change as user
PushOneCommit.Result r2 = amendChange(r1.getChangeId(), "refs/drafts/master", user, userTestRepo);
r2.assertErrorStatus("cannot add patch set to " + r1.getChange().getId().id + ".");
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class StickyApprovalsIT method createChangeForMergeCommit.
private String createChangeForMergeCommit() throws Exception {
ObjectId initial = repo().exactRef(HEAD).getLeaf().getObjectId();
PushOneCommit.Result parent1 = createChange("parent 1", "p1.txt", "content 1");
testRepo.reset(initial);
PushOneCommit.Result parent2 = createChange("parent 2", "p2.txt", "content 2");
testRepo.reset(parent1.getCommit());
PushOneCommit merge = pushFactory.create(db, admin.getIdent(), testRepo);
merge.setParents(ImmutableList.of(parent1.getCommit(), parent2.getCommit()));
PushOneCommit.Result result = merge.to("refs/for/master");
result.assertOkStatus();
return result.getChangeId();
}
Aggregations