use of com.google.gerrit.server.restapi.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/", BanCommitInput.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()).contains("contains banned commit");
}
use of com.google.gerrit.server.restapi.project.BanCommit.BanResultInfo in project gerrit by GerritCodeReview.
the class BanCommitCommand method run.
@Override
protected void run() throws Failure {
enableGracefulStop();
try {
BanCommitInput input = BanCommitInput.fromCommits(Lists.transform(commitsToBan, ObjectId::getName));
input.reason = reason;
BanResultInfo r = banCommit.apply(new ProjectResource(projectState, user), input).value();
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 (Exception e) {
throw die(e);
}
}
use of com.google.gerrit.server.restapi.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/", BanCommitInput.fromCommits("a8a477efffbbf3b44169bb9a1d3a334cbbd9aa96"));
r.consume();
r = adminRestSession.put("/projects/" + project.get() + "/ban/", BanCommitInput.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();
}
Aggregations