Search in sources :

Example 31 with PushOneCommit

use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.

the class ChangeIT method unresolvedCommentsBlocked.

@Sandboxed
@Test
public void unresolvedCommentsBlocked() throws Exception {
    RevCommit oldHead = getRemoteHead();
    GitUtil.fetch(testRepo, RefNames.REFS_CONFIG + ":config");
    testRepo.reset("config");
    PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, "Configure", "rules.pl", "submit_rule(submit(R)) :- \n" + "gerrit:unresolved_comments_count(0), \n" + "!," + "gerrit:commit_author(A), \n" + "R = label('All-Comments-Resolved', ok(A)).\n" + "submit_rule(submit(R)) :- \n" + "gerrit:unresolved_comments_count(U), \n" + "U > 0," + "R = label('All-Comments-Resolved', need(_)). \n\n");
    push.to(RefNames.REFS_CONFIG);
    testRepo.reset(oldHead);
    oldHead = getRemoteHead();
    PushOneCommit.Result result1 = pushFactory.create(db, user.getIdent(), testRepo).to("refs/for/master");
    testRepo.reset(oldHead);
    PushOneCommit.Result result2 = pushFactory.create(db, user.getIdent(), testRepo).to("refs/for/master");
    addComment(result1, "comment 1", true, false, null);
    addComment(result2, "comment 2", true, true, null);
    gApi.changes().id(result1.getChangeId()).current().submit();
    exception.expect(ResourceConflictException.class);
    exception.expectMessage("Failed to submit 1 change due to the following problems:\n" + "Change 2: needs All-Comments-Resolved");
    gApi.changes().id(result2.getChangeId()).current().submit();
}
Also used : PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) RevCommit(org.eclipse.jgit.revwalk.RevCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test) Sandboxed(com.google.gerrit.acceptance.Sandboxed)

Example 32 with PushOneCommit

use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.

the class AbstractPushForReview method pushSameCommitTwiceUsingMagicBranchBaseOption.

@Test
public void pushSameCommitTwiceUsingMagicBranchBaseOption() throws Exception {
    grant(project, "refs/heads/master", Permission.PUSH);
    PushOneCommit.Result rBase = pushTo("refs/heads/master");
    rBase.assertOkStatus();
    gApi.projects().name(project.get()).branch("foo").create(new BranchInput());
    PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent");
    PushOneCommit.Result r = push.to("refs/for/master");
    r.assertOkStatus();
    PushResult pr = GitUtil.pushHead(testRepo, "refs/for/foo%base=" + rBase.getCommit().name(), false, false);
    // BatchUpdate implementations differ in how they hook into progress monitors. We mostly just
    // care that there is a new change.
    assertThat(pr.getMessages()).containsMatch("changes: new: 1,( refs: 1)? done");
    assertTwoChangesWithSameRevision(r);
}
Also used : BranchInput(com.google.gerrit.extensions.api.projects.BranchInput) PushResult(org.eclipse.jgit.transport.PushResult) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 33 with PushOneCommit

use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.

the class AbstractPushForReview method pushCommitUsingSignedOffBy.

@Test
public void pushCommitUsingSignedOffBy() throws Exception {
    PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent");
    PushOneCommit.Result r = push.to("refs/for/master");
    r.assertOkStatus();
    setUseSignedOffBy(InheritableBoolean.TRUE);
    blockForgeCommitter(project, "refs/heads/master");
    push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT + String.format("\n\nSigned-off-by: %s <%s>", admin.fullName, admin.email), "b.txt", "anotherContent");
    r = push.to("refs/for/master");
    r.assertOkStatus();
    push = pushFactory.create(db, admin.getIdent(), testRepo, PushOneCommit.SUBJECT, "b.txt", "anotherContent");
    r = push.to("refs/for/master");
    r.assertErrorStatus("not Signed-off-by author/committer/uploader in commit message footer");
}
Also used : PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest) Test(org.junit.Test)

Example 34 with PushOneCommit

use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.

the class SubmitOnPushIT method submitOnPushWithTag.

@Test
public void submitOnPushWithTag() throws Exception {
    grant(project, "refs/for/refs/heads/master", Permission.SUBMIT);
    grant(project, "refs/tags/*", Permission.CREATE);
    grant(project, "refs/tags/*", Permission.PUSH);
    PushOneCommit.Tag tag = new PushOneCommit.Tag("v1.0");
    PushOneCommit push = pushFactory.create(db, admin.getIdent(), testRepo);
    push.setTag(tag);
    PushOneCommit.Result r = push.to("refs/for/master%submit");
    r.assertOkStatus();
    r.assertChange(Change.Status.MERGED, null, admin);
    assertSubmitApproval(r.getPatchSetId());
    assertCommit(project, "refs/heads/master");
    assertTag(project, "refs/heads/master", tag);
}
Also used : RevTag(org.eclipse.jgit.revwalk.RevTag) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Example 35 with PushOneCommit

use of com.google.gerrit.acceptance.PushOneCommit in project gerrit by GerritCodeReview.

the class ConfigChangeIT method rejectDoubleInheritance.

@Test
public void rejectDoubleInheritance() throws Exception {
    setApiUser(admin);
    // Create separate projects to test the config
    Project.NameKey parent = createProject("projectToInheritFrom");
    Project.NameKey child = createProject("projectWithMalformedConfig");
    String config = gApi.projects().name(child.get()).branch(RefNames.REFS_CONFIG).file("project.config").asString();
    // Append and push malformed project config
    String pattern = "[access]\n\tinheritFrom = " + allProjects.get() + "\n";
    String doubleInherit = pattern + "\tinheritFrom = " + parent.get() + "\n";
    config = config.replace(pattern, doubleInherit);
    TestRepository<InMemoryRepository> childRepo = cloneProject(child, admin);
    // Fetch meta ref
    GitUtil.fetch(childRepo, RefNames.REFS_CONFIG + ":cfg");
    childRepo.reset("cfg");
    PushOneCommit push = pushFactory.create(db, admin.getIdent(), childRepo, "Subject", "project.config", config);
    PushOneCommit.Result res = push.to(RefNames.REFS_CONFIG);
    res.assertErrorStatus();
    res.assertMessage("cannot inherit from multiple projects");
}
Also used : Project(com.google.gerrit.reviewdb.client.Project) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) PushOneCommit(com.google.gerrit.acceptance.PushOneCommit) Test(org.junit.Test) AbstractDaemonTest(com.google.gerrit.acceptance.AbstractDaemonTest)

Aggregations

PushOneCommit (com.google.gerrit.acceptance.PushOneCommit)91 Test (org.junit.Test)76 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)72 InMemoryRepository (org.eclipse.jgit.internal.storage.dfs.InMemoryRepository)17 ChangeInfo (com.google.gerrit.extensions.common.ChangeInfo)14 ProjectConfig (com.google.gerrit.server.git.ProjectConfig)13 RevCommit (org.eclipse.jgit.revwalk.RevCommit)13 Project (com.google.gerrit.reviewdb.client.Project)11 ReviewInput (com.google.gerrit.extensions.api.changes.ReviewInput)9 BranchInput (com.google.gerrit.extensions.api.projects.BranchInput)7 CommentInput (com.google.gerrit.extensions.api.changes.ReviewInput.CommentInput)6 ImmutableList (com.google.common.collect.ImmutableList)5 DeleteCommentInput (com.google.gerrit.extensions.api.changes.DeleteCommentInput)5 CommentInfo (com.google.gerrit.extensions.common.CommentInfo)5 IdString (com.google.gerrit.extensions.restapi.IdString)5 AccountGroup (com.google.gerrit.reviewdb.client.AccountGroup)5 ArrayList (java.util.ArrayList)5 ObjectId (org.eclipse.jgit.lib.ObjectId)5 AddReviewerInput (com.google.gerrit.extensions.api.changes.AddReviewerInput)4 ChangeApi (com.google.gerrit.extensions.api.changes.ChangeApi)4