in src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/InvalidLineEndingValidator.java [130:151]
List<CommitValidationMessage> performValidation(
Repository repo, RevCommit c, RevWalk revWalk, PluginConfig cfg)
throws IOException, ExecutionException {
List<CommitValidationMessage> messages = new LinkedList<>();
Map<String, ObjectId> content = CommitUtils.getChangedContent(repo, c, revWalk);
for (String path : content.keySet()) {
ObjectLoader ol = revWalk.getObjectReader().open(content.get(path));
try (InputStream in = ol.openStream()) {
if (RawText.isBinary(in) || contentTypeUtil.isForbiddenBinaryContentType(ol, path, cfg)) {
continue;
}
}
try (InputStreamReader isr = new InputStreamReader(ol.openStream(), StandardCharsets.UTF_8)) {
if (doesInputStreanContainCR(isr)) {
messages.add(
new CommitValidationMessage(
"found carriage return (CR) character in file: " + path, true));
}
}
}
return messages;
}