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();
}
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);
}
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");
}
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);
}
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");
}
Aggregations