List performValidation()

in src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/ContentTypeValidator.java [152:170]


  List<CommitValidationMessage> performValidation(
      Repository repo, RevCommit c, RevWalk revWalk, String[] blockedTypes, boolean allowList)
      throws IOException, ExecutionException {
    List<CommitValidationMessage> messages = new LinkedList<>();
    Map<String, ObjectId> content = CommitUtils.getChangedContent(repo, c, revWalk);
    for (String path : content.keySet()) {
      ObjectLoader ol = repo.open(content.get(path));
      try (ObjectStream os = ol.openStream()) {
        String contentType = contentTypeUtil.getContentType(os, path);
        if ((contentTypeUtil.matchesAny(contentType, blockedTypes) && !allowList)
            || (!contentTypeUtil.matchesAny(contentType, blockedTypes) && allowList)) {
          messages.add(
              new CommitValidationMessage(
                  "found blocked content type (" + contentType + ") in file: " + path, true));
        }
      }
    }
    return messages;
  }