in src/main/java/com/googlesource/gerrit/plugins/quota/QuotaFinder.java [33:57]
public QuotaSection firstMatching(Project.NameKey project) {
Config cfg = projectCache.getAllProjects().getConfig("quota.config").get();
Set<String> namespaces = cfg.getSubsections(QuotaSection.QUOTA);
String p = project.get();
for (String n : namespaces) {
if ("?/*".equals(n) || n.endsWith("/?/*")) {
String prefix = n.substring(0, n.length() - 3);
Matcher m = Pattern.compile("^" + prefix + "([^/]+)/.*$").matcher(p);
if (m.matches()) {
return new QuotaSection(cfg, n, prefix + m.group(1) + "/*");
}
} else if (n.endsWith("/*")) {
if (p.startsWith(n.substring(0, n.length() - 1))) {
return new QuotaSection(cfg, n);
}
} else if (n.startsWith("^")) {
if (p.matches(n.substring(1))) {
return new QuotaSection(cfg, n);
}
} else if (p.equals(n)) {
return new QuotaSection(cfg, n);
}
}
return null;
}