in src/main/java/com/googlesource/gerrit/plugins/uploadvalidator/MaxPathLengthValidator.java [85:113]
public List<CommitValidationMessage> onCommitReceived(CommitReceivedEvent receiveEvent)
throws CommitValidationException {
try {
PluginConfig cfg =
cfgFactory.getFromProjectConfigWithInheritance(
receiveEvent.project.getNameKey(), pluginName);
if (isActive(cfg)
&& validatorConfig.isEnabled(
receiveEvent.user,
receiveEvent.getProjectNameKey(),
receiveEvent.getRefName(),
KEY_MAX_PATH_LENGTH,
receiveEvent.pushOptions)) {
int maxPathLength = cfg.getInt(KEY_MAX_PATH_LENGTH, 0);
try (Repository repo = repoManager.openRepository(receiveEvent.project.getNameKey())) {
List<CommitValidationMessage> messages =
performValidation(repo, receiveEvent.commit, receiveEvent.revWalk, maxPathLength);
if (!messages.isEmpty()) {
throw new CommitValidationException(
"contains files with too long paths (max path length: " + maxPathLength + ")",
messages);
}
}
}
} catch (NoSuchProjectException | IOException e) {
throw new CommitValidationException("failed to check for max file path length", e);
}
return Collections.emptyList();
}