in src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/ContentTypeValidator.java [119:149]
public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent)
throws CommitValidationException {
try {
PluginConfig cfg =
cfgFactory.getFromProjectConfigWithInheritance(
receiveEvent.project.getNameKey(), pluginName);
if (isActive(cfg)
&& validatorConfig.isEnabled(
receiveEvent.user,
receiveEvent.getProjectNameKey(),
receiveEvent.getRefName(),
KEY_BLOCKED_CONTENT_TYPE,
receiveEvent.pushOptions)) {
try (Repository repo = repoManager.openRepository(receiveEvent.project.getNameKey())) {
List<CommitValidationMessage> messages =
performValidation(
repo,
receiveEvent.commit,
receiveEvent.revWalk,
getBlockedTypes(cfg),
isAllowList(cfg));
if (!messages.isEmpty()) {
throw new CommitValidationException("contains blocked content type", messages);
}
}
}
} catch (NoSuchProjectException | IOException | ExecutionException e) {
throw new CommitValidationException("failed to check on content type", e);
}
return Collections.emptyList();
}