in src/main/java/com/googlesource/gerrit/plugins/findowners/OwnersValidator.java [329:385]
void checkIncludeOrFile(String project, String path, int num, String line) {
// project is the including file's project, not necessarily the same as CL event's.
String directive = Parser.getIncludeOrFile(line);
String[] KPF = Parser.parseInclude(project, directive);
if (KPF == null || KPF[1] == null || KPF[2] == null) {
addSyntaxError(qualifiedPath(project, path), num, line);
}
String file = KPF[2];
String curDir = Util.getParentDir(path);
String repoFile = normalizeChangedFilePath(curDir, file);
// Check each file only once.
String key = KPF[1] + ":" + repoFile;
if (checkedFiles.contains(key)) {
addVerboseMsg("skip repeated include of " + key);
return;
}
checkedFiles.add(key);
if (KPF[1].equals(event.project.getName())) {
if (allFiles.get(repoFile) != null) {
// Case (1): included file is in current CL.
addVerboseMsg("check changed file " + key);
try {
ObjectLoader ol = event.revWalk.getObjectReader().open(allFiles.get(repoFile));
try (InputStream in = ol.openStream()) {
if (RawText.isBinary(in)) {
addError(path + " is a binary file"); // OWNERS files cannot be binary
return;
}
}
checkFile(KPF[1], repoFile, ol);
} catch (Exception e) {
addError("cannot open changed file: " + path);
}
return;
}
}
// Included file is in repository or other CL.
addVerboseMsg("check repo file " + key);
String content =
OwnersDb.getRepoFile(
null, /* permissionBackend */
readFiles,
repoManager,
null,
null,
KPF[1],
event.refName,
repoFile,
new ArrayList<>());
if (isNullOrEmpty(content)) { // file not found or not readable.
addVerboseMsg("cannot find file: " + key);
// unchecked: including-file-path : line number : source line
addMsg("unchecked: " + qualifiedPath(project, path) + ":" + num + ": " + directive);
} else {
checkFile(KPF[1], repoFile, content);
}
}