Fix task quota namespacing
`.git` extension only appears when user specifies it, so make the regex
independent of it. Also, use the Namekey#parse function to remove that
extension and trailing slashes. Some gerrit installations might also
have a leading slash and hence makes it optional.
Change-Id: I772e50046dbdd276e13438749767434d7cb3f430
diff --git a/src/main/java/com/googlesource/gerrit/plugins/quota/TaskQuotas.java b/src/main/java/com/googlesource/gerrit/plugins/quota/TaskQuotas.java
index 40aaa36..0119c42 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/quota/TaskQuotas.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/quota/TaskQuotas.java
@@ -39,7 +39,7 @@
private final QuotaFinder quotaFinder;
private final Map<Integer, List<TaskQuota>> quotasByTask = new ConcurrentHashMap<>();
private final Map<QuotaSection, List<TaskQuota>> quotasByNamespace = new HashMap<>();
- private final Pattern PROJECT_PATTERN = Pattern.compile("\\s+(.*\\.git)\\s+(\\S+)$");
+ private final Pattern PROJECT_PATTERN = Pattern.compile("\\s+/?(.*)\\s+(\\(\\S+\\))$");
private final Config quotaConfig;
private final TaskQuota.BuildInfo baseBuildInfo;
@@ -123,6 +123,6 @@
private Optional<Project.NameKey> estimateProject(WorkQueue.Task<?> task) {
Matcher matcher = PROJECT_PATTERN.matcher(task.toString());
- return matcher.find() ? Optional.of(Project.nameKey(matcher.group(1))) : Optional.empty();
+ return matcher.find() ? Optional.of(Project.NameKey.parse(matcher.group(1))) : Optional.empty();
}
}