Search in sources :

Example 96 with PushOneCommit

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);
}
Also used : RevisionApi(com.google.gerrit.extensions.api.changes.RevisionApi) ReviewInput(com.google.gerrit.extensions.api.changes.ReviewInput) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit)

Example 97 with PushOneCommit

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();
}
Also used : ObjectId(org.eclipse.jgit.lib.ObjectId) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit)

Example 98 with PushOneCommit

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();
}
Also used : PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 99 with PushOneCommit

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();
}
Also used : PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 100 with PushOneCommit

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;
}
Also used : PushOneCommit(com.google.gerrit.acceptance.PushOneCommit)

Aggregations

PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)191 Test (org.junit.Test)162 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)149 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)29 Registration (com.google.gerrit.acceptance.ExtensionRegistry.Registration)28 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)26 RevCommit (org.eclipse.jgit.revwalk.RevCommit)20 ArrayList (java.util.ArrayList)17 GerritConfig (com.google.gerrit.acceptance.config.GerritConfig)15 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)15 Project (com.google.gerrit.entities.Project)14 BranchInput (com.google.gerrit.extensions.api.projects.BranchInput)14 Result (com.google.gerrit.acceptance.PushOneCommit.Result)10 ObjectId (org.eclipse.jgit.lib.ObjectId)10 ImmutableList (com.google.common.collect.ImmutableList)9 List (java.util.List)9 CommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput)8 Config (org.eclipse.jgit.lib.Config)8 CommentInfo (com.google.gerrit.extensions.common.CommentInfo)7 IdString (com.google.gerrit.extensions.restapi.IdString)7