use of com.google.gerrit.server.git.validators.CommitValidators in project gerrit by GerritCodeReview.
the class ReceiveCommits method validCommit.
private boolean validCommit(RevWalk rw, RefControl ctl, ReceiveCommand cmd, ObjectId id) throws IOException {
if (validCommits.contains(id)) {
return true;
}
RevCommit c = rw.parseCommit(id);
rw.parseBody(c);
try (CommitReceivedEvent receiveEvent = new CommitReceivedEvent(cmd, project, ctl.getRefName(), rw.getObjectReader(), c, user)) {
boolean isMerged = magicBranch != null && cmd.getRefName().equals(magicBranch.cmd.getRefName()) && magicBranch.merged;
CommitValidators validators = isMerged ? commitValidatorsFactory.forMergedCommits(ctl) : commitValidatorsFactory.forReceiveCommits(ctl, sshInfo, repo, rw);
messages.addAll(validators.validate(receiveEvent));
} catch (CommitValidationException e) {
logDebug("Commit validation failed on {}", c.name());
messages.addAll(e.getMessages());
reject(cmd, e.getMessage());
return false;
}
validCommits.add(c.copy());
return true;
}
Aggregations