in src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/InvalidLineEndingValidator.java [101:127]
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_CHECK_REJECT_WINDOWS_LINE_ENDINGS,
receiveEvent.pushOptions)) {
try (Repository repo = repoManager.openRepository(receiveEvent.project.getNameKey())) {
List<CommitValidationMessage> messages =
performValidation(repo, receiveEvent.commit, receiveEvent.revWalk, cfg);
if (!messages.isEmpty()) {
throw new CommitValidationException(
"contains files with a Windows line ending", messages);
}
}
}
} catch (NoSuchProjectException | IOException | ExecutionException e) {
throw new CommitValidationException("failed to check on Windows line endings", e);
}
return Collections.emptyList();
}