in java/com/google/gerrit/plugins/codeowners/backend/CodeOwnerConfigHierarchy.java [187:254]
private void visit(
BranchNameKey branchNameKey,
@Nullable ObjectId revision,
Path absolutePath,
Path startFolder,
PathCodeOwnersVisitor pathCodeOwnersVisitor,
Consumer<CodeOwnerConfig.Key> parentCodeOwnersIgnoredCallback) {
requireNonNull(branchNameKey, "branch");
requireNonNull(absolutePath, "absolutePath");
requireNonNull(pathCodeOwnersVisitor, "pathCodeOwnersVisitor");
requireNonNull(parentCodeOwnersIgnoredCallback, "parentCodeOwnersIgnoredCallback");
checkState(absolutePath.isAbsolute(), "path %s must be absolute", absolutePath);
logger.atFine().log(
"visiting code owner configs for '%s' in branch '%s' in project '%s' (revision = '%s')",
absolutePath,
branchNameKey.shortName(),
branchNameKey.project(),
revision != null ? revision.name() : "n/a");
if (revision != null) {
// Next path in which we look for a code owner configuration. We start at the given folder and
// then go up the parent hierarchy.
Path ownerConfigFolder = startFolder;
// Iterate over the parent code owner configurations.
while (ownerConfigFolder != null) {
// Read code owner config and invoke the codeOwnerConfigVisitor if the code owner config
// exists.
logger.atFine().log("inspecting code owner config for %s", ownerConfigFolder);
CodeOwnerConfig.Key codeOwnerConfigKey =
CodeOwnerConfig.Key.create(branchNameKey, ownerConfigFolder);
Optional<PathCodeOwners> pathCodeOwners =
pathCodeOwnersFactory.create(
transientCodeOwnerConfigCache, codeOwnerConfigKey, revision, absolutePath);
if (pathCodeOwners.isPresent()) {
logger.atFine().log("visit code owner config for %s", ownerConfigFolder);
boolean visitFurtherCodeOwnerConfigs = pathCodeOwnersVisitor.visit(pathCodeOwners.get());
boolean ignoreParentCodeOwners =
pathCodeOwners.get().resolveCodeOwnerConfig().get().ignoreParentCodeOwners();
if (ignoreParentCodeOwners) {
parentCodeOwnersIgnoredCallback.accept(codeOwnerConfigKey);
}
logger.atFine().log(
"visitFurtherCodeOwnerConfigs = %s, ignoreParentCodeOwners = %s",
visitFurtherCodeOwnerConfigs, ignoreParentCodeOwners);
if (!visitFurtherCodeOwnerConfigs || ignoreParentCodeOwners) {
// If no further code owner configs should be visited or if all parent code owner
// configs are ignored, we are done.
// No need to check further parent code owner configs (including the default code owner
// config in refs/meta/config which is the parent of the root code owner config), hence
// we can return here.
return;
}
} else {
logger.atFine().log("no code owner config found in %s", ownerConfigFolder);
}
// Continue the loop with the next parent folder.
ownerConfigFolder = ownerConfigFolder.getParent();
}
}
if (!RefNames.REFS_CONFIG.equals(branchNameKey.branch())) {
visitCodeOwnerConfigInRefsMetaConfig(
branchNameKey.project(), absolutePath, pathCodeOwnersVisitor);
}
}