List performValidation()

in src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/BlockedKeywordValidator.java [221:256]


  List<CommitValidationMessage> performValidation(
      Project.NameKey project,
      Repository repo,
      RevCommit c,
      RevWalk revWalk,
      ImmutableCollection<Pattern> blockedKeywordPatterns,
      PluginConfig cfg)
      throws IOException, ExecutionException, DiffNotAvailableException {
    List<CommitValidationMessage> messages = new LinkedList<>();
    checkCommitMessageForBlockedKeywords(blockedKeywordPatterns, messages, c.getFullMessage());
    Map<String, ObjectId> content = CommitUtils.getChangedContent(repo, c, revWalk);
    Map<String, FileDiffOutput> fileDiffs =
        diffOperations.listModifiedFilesAgainstParent(
            project, c, /* parentNum = */ 0, DiffOptions.DEFAULTS);

    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;
        }
      }
      if (!fileDiffs.containsKey(path)) {
        continue;
      }
      checkLineDiffForBlockedKeywords(
          fileDiffs.get(path).edits().stream()
              .map(TaggedEdit::jgitEdit)
              .collect(Collectors.toList()),
          blockedKeywordPatterns,
          messages,
          path,
          ol);
    }
    return messages;
  }