Merge changes from topic "issue-10763" into stable-2.15
* changes:
ProjectControl: Allow regexes ref strings for uploads
ProjectControl: Allow regexes ref strings for tags
ProjectControl: Reuse constants for ref strings
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectControl.java b/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectControl.java
index e97411e..76e9e98 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectControl.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/project/ProjectControl.java
@@ -15,7 +15,10 @@
package com.google.gerrit.server.project;
import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.gerrit.common.data.AccessSection.ALL;
+import static com.google.gerrit.common.data.RefConfigSection.REGEX_PREFIX;
import static com.google.gerrit.reviewdb.client.RefNames.REFS_TAGS;
+import static com.google.gerrit.server.util.MagicBranch.NEW_CHANGE;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
@@ -203,7 +206,7 @@
/** Is this user a project owner? */
public boolean isOwner() {
- return (isDeclaredOwner() && !controlForRef("refs/*").isBlocked(Permission.OWNER)) || isAdmin();
+ return (isDeclaredOwner() && !controlForRef(ALL).isBlocked(Permission.OWNER)) || isAdmin();
}
/**
@@ -259,7 +262,8 @@
private boolean canCreateChanges() {
for (SectionMatcher matcher : access()) {
AccessSection section = matcher.section;
- if (section.getName().startsWith("refs/for/")) {
+ if (section.getName().startsWith(NEW_CHANGE)
+ || section.getName().startsWith(REGEX_PREFIX + NEW_CHANGE)) {
Permission permission = section.getPermission(Permission.PUSH);
if (permission != null && controlForRef(section.getName()).canPerform(Permission.PUSH)) {
return true;
@@ -290,7 +294,8 @@
for (SectionMatcher matcher : access()) {
AccessSection section = matcher.section;
- if (section.getName().startsWith(REFS_TAGS)) {
+ if (section.getName().startsWith(REFS_TAGS)
+ || section.getName().startsWith(REGEX_PREFIX + REFS_TAGS)) {
Permission permission = section.getPermission(permissionName);
if (permission == null) {
continue;
@@ -344,7 +349,7 @@
private boolean canPerformOnAllRefs(String permission, Set<String> ignore) {
boolean canPerform = false;
Set<String> patterns = allRefPatterns(permission);
- if (patterns.contains(AccessSection.ALL)) {
+ if (patterns.contains(ALL)) {
// Only possible if granted on the pattern that
// matches every possible reference. Check all
// patterns also have the permission.