use of com.google.gerrit.server.project.BanCommit.BanResultInfo in project gerrit by GerritCodeReview.
the class BanCommitIT method banCommit.
@Test
public void banCommit() throws Exception {
RevCommit c = commitBuilder().add("a.txt", "some content").create();
RestResponse r = adminRestSession.put("/projects/" + project.get() + "/ban/", BanCommit.Input.fromCommits(c.name()));
r.assertOK();
BanResultInfo info = newGson().fromJson(r.getReader(), BanResultInfo.class);
assertThat(Iterables.getOnlyElement(info.newlyBanned)).isEqualTo(c.name());
assertThat(info.alreadyBanned).isNull();
assertThat(info.ignored).isNull();
RemoteRefUpdate u = pushHead(testRepo, "refs/heads/master", false).getRemoteUpdate("refs/heads/master");
assertThat(u).isNotNull();
assertThat(u.getStatus()).isEqualTo(REJECTED_OTHER_REASON);
assertThat(u.getMessage()).startsWith("contains banned commit");
}
use of com.google.gerrit.server.project.BanCommit.BanResultInfo in project gerrit by GerritCodeReview.
the class BanCommitIT method banAlreadyBannedCommit.
@Test
public void banAlreadyBannedCommit() throws Exception {
RestResponse r = adminRestSession.put("/projects/" + project.get() + "/ban/", BanCommit.Input.fromCommits("a8a477efffbbf3b44169bb9a1d3a334cbbd9aa96"));
r.consume();
r = adminRestSession.put("/projects/" + project.get() + "/ban/", BanCommit.Input.fromCommits("a8a477efffbbf3b44169bb9a1d3a334cbbd9aa96"));
r.assertOK();
BanResultInfo info = newGson().fromJson(r.getReader(), BanResultInfo.class);
assertThat(Iterables.getOnlyElement(info.alreadyBanned)).isEqualTo("a8a477efffbbf3b44169bb9a1d3a334cbbd9aa96");
assertThat(info.newlyBanned).isNull();
assertThat(info.ignored).isNull();
}
use of com.google.gerrit.server.project.BanCommit.BanResultInfo in project gerrit by GerritCodeReview.
the class BanCommitCommand method run.
@Override
protected void run() throws Failure {
try {
BanCommit.Input input = BanCommit.Input.fromCommits(Lists.transform(commitsToBan, ObjectId::getName));
input.reason = reason;
BanResultInfo r = banCommit.apply(new ProjectResource(projectControl), input);
printCommits(r.newlyBanned, "The following commits were banned");
printCommits(r.alreadyBanned, "The following commits were already banned");
printCommits(r.ignored, "The following ids do not represent commits and were ignored");
} catch (RestApiException | IOException e) {
throw die(e);
}
}
Aggregations