in java/com/google/gerrit/plugins/codeowners/backend/config/BackendConfig.java [106:168]
ImmutableList<CommitValidationMessage> validateProjectLevelConfig(
String fileName, Config projectLevelConfig) {
requireNonNull(fileName, "fileName");
requireNonNull(projectLevelConfig, "projectLevelConfig");
ImmutableList.Builder<CommitValidationMessage> validationMessages = ImmutableList.builder();
String backendName = projectLevelConfig.getString(SECTION_CODE_OWNERS, null, KEY_BACKEND);
if (backendName != null) {
if (!lookupBackend(backendName).isPresent()) {
validationMessages.add(
new CommitValidationMessage(
String.format(
"Code owner backend '%s' that is configured in %s (parameter %s.%s) not found.",
backendName, fileName, SECTION_CODE_OWNERS, KEY_BACKEND),
ValidationMessage.Type.ERROR));
}
}
String pathExpressionsName =
projectLevelConfig.getString(SECTION_CODE_OWNERS, null, KEY_PATH_EXPRESSIONS);
if (!Strings.isNullOrEmpty(pathExpressionsName)
&& !PathExpressions.tryParse(pathExpressionsName).isPresent()) {
validationMessages.add(
new CommitValidationMessage(
String.format(
"Path expressions '%s' that are configured in %s (parameter %s.%s) not found.",
pathExpressionsName, fileName, SECTION_CODE_OWNERS, KEY_PATH_EXPRESSIONS),
ValidationMessage.Type.ERROR));
}
for (String subsection : projectLevelConfig.getSubsections(SECTION_CODE_OWNERS)) {
backendName = projectLevelConfig.getString(SECTION_CODE_OWNERS, subsection, KEY_BACKEND);
if (backendName != null) {
if (!lookupBackend(backendName).isPresent()) {
validationMessages.add(
new CommitValidationMessage(
String.format(
"Code owner backend '%s' that is configured in %s (parameter %s.%s.%s) not found.",
backendName, fileName, SECTION_CODE_OWNERS, subsection, KEY_BACKEND),
ValidationMessage.Type.ERROR));
}
}
pathExpressionsName =
projectLevelConfig.getString(SECTION_CODE_OWNERS, subsection, KEY_PATH_EXPRESSIONS);
if (!Strings.isNullOrEmpty(pathExpressionsName)
&& !PathExpressions.tryParse(pathExpressionsName).isPresent()) {
validationMessages.add(
new CommitValidationMessage(
String.format(
"Path expressions '%s' that are configured in %s (parameter %s.%s.%s) not found.",
pathExpressionsName,
fileName,
SECTION_CODE_OWNERS,
subsection,
KEY_PATH_EXPRESSIONS),
ValidationMessage.Type.ERROR));
}
}
return validationMessages.build();
}