use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class ChangeKindCreator method trivialRebase.
private void trivialRebase(String changeId, TestRepository<InMemoryRepository> testRepo, TestAccount user, Project.NameKey project) throws Exception {
requestScopeOperations.setApiUser(user.id());
testRepo.reset(projectOperations.project(project).getHead("master"));
PushOneCommit push = pushFactory.create(user.newIdent(), testRepo, "Other Change", "a" + System.nanoTime() + ".txt", PushOneCommit.FILE_CONTENT);
PushOneCommit.Result r = push.to("refs/for/master");
r.assertOkStatus();
RevisionApi revision = gApi.changes().id(r.getChangeId()).current();
ReviewInput in = new ReviewInput().label(LabelId.CODE_REVIEW, 2).label(LabelId.VERIFIED, 1);
revision.review(in);
revision.submit();
gApi.changes().id(changeId).current().rebase();
assertThat(getChangeKind(changeId)).isEqualTo(ChangeKind.TRIVIAL_REBASE);
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class ChangeKindCreator method createChangeForMergeCommit.
/**
* Creates a change that is a merge {@link ChangeKind} and returns the change id.
*/
public String createChangeForMergeCommit(TestRepository<InMemoryRepository> testRepo, TestAccount user) throws Exception {
ObjectId initial = testRepo.getRepository().exactRef(HEAD).getLeaf().getObjectId();
PushOneCommit.Result parent1 = createChange("parent 1", "p1.txt", "content 1", testRepo, user);
testRepo.reset(initial);
PushOneCommit.Result parent2 = createChange("parent 2", "p2.txt", "content 2", testRepo, user);
testRepo.reset(parent1.getCommit());
PushOneCommit merge = pushFactory.create(user.newIdent(), testRepo);
merge.setParents(ImmutableList.of(parent1.getCommit(), parent2.getCommit()));
PushOneCommit.Result result = merge.to("refs/for/master");
result.assertOkStatus();
return result.getChangeId();
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class AgreementsIT method publishEditRestWithoutCLA.
@Test
public void publishEditRestWithoutCLA() throws Exception {
String filename = "foo";
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo, "subject1", filename, "contentold");
PushOneCommit.Result result = push.to("refs/for/master");
result.assertOkStatus();
String changeId = result.getChangeId();
gApi.changes().id(changeId).edit().create();
gApi.changes().id(changeId).edit().modifyFile(filename, RawInputUtil.create("newcontent".getBytes(UTF_8)));
String url = "/changes/" + changeId + "/edit:publish";
setUseContributorAgreements(InheritableBoolean.TRUE);
userRestSession.post(url).assertForbidden();
setUseContributorAgreements(InheritableBoolean.FALSE);
userRestSession.post(url).assertNoContent();
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class PrivateChangeIT method mergingPrivateChangeThroughGitPublishesIt.
@Test
public void mergingPrivateChangeThroughGitPublishesIt() throws Exception {
PushOneCommit.Result r = createChange();
gApi.changes().id(r.getChangeId()).setPrivate(true);
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo);
PushOneCommit.Result result = push.to("refs/heads/master");
result.assertOkStatus();
assertThat(gApi.changes().id(r.getChangeId()).get().isPrivate).isNull();
}
use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.
the class SubmitTypeRuleIT method createChange.
private PushOneCommit.Result createChange(String dest, String subject) throws Exception {
PushOneCommit push = pushFactory.create(admin.newIdent(), testRepo, subject, "file" + fileCounter.incrementAndGet(), PushOneCommit.FILE_CONTENT);
PushOneCommit.Result r = push.to("refs/for/" + dest);
r.assertOkStatus();
return r;
}
Aggregations