summaryrefslogtreecommitdiffstats
path: root/java/com/google/gerrit/reviewdb/client/RefNames.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/com/google/gerrit/reviewdb/client/RefNames.java')
-rw-r--r--java/com/google/gerrit/reviewdb/client/RefNames.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/java/com/google/gerrit/reviewdb/client/RefNames.java b/java/com/google/gerrit/reviewdb/client/RefNames.java
index fd2fb56b0e..994a299ef1 100644
--- a/java/com/google/gerrit/reviewdb/client/RefNames.java
+++ b/java/com/google/gerrit/reviewdb/client/RefNames.java
@@ -118,6 +118,11 @@ public class RefNames {
return shard(id.get(), r).append(META_SUFFIX).toString();
}
+ public static String patchSetRef(PatchSet.Id id) {
+ StringBuilder r = newStringBuilder().append(REFS_CHANGES);
+ return shard(id.changeId.get(), r).append('/').append(id.get()).toString();
+ }
+
public static String robotCommentsRef(Change.Id id) {
StringBuilder r = newStringBuilder().append(REFS_CHANGES);
return shard(id.get(), r).append(ROBOT_COMMENTS_SUFFIX).toString();
@@ -263,6 +268,31 @@ public class RefNames {
return REFS_CONFIG.equals(ref);
}
+ /**
+ * Whether the ref is managed by Gerrit. Covers all Gerrit-internal refs like refs/cache-automerge
+ * and refs/meta as well as refs/changes. Does not cover user-created refs like branches or custom
+ * ref namespaces like refs/my-company.
+ *
+ * <p>Any ref for which this method evaluates to true will be served to users who have the {@code
+ * ACCESS_DATABASE} capability.
+ *
+ * <p><b>Caution</b>Any ref not in this list will be served if the user was granted a READ
+ * permission on it using Gerrit's permission model.
+ */
+ public static boolean isGerritRef(String ref) {
+ return ref.startsWith(REFS_CHANGES)
+ || ref.startsWith(REFS_EXTERNAL_IDS)
+ || ref.startsWith(REFS_CACHE_AUTOMERGE)
+ || ref.startsWith(REFS_DRAFT_COMMENTS)
+ || ref.startsWith(REFS_DELETED_GROUPS)
+ || ref.startsWith(REFS_SEQUENCES)
+ || ref.startsWith(REFS_GROUPS)
+ || ref.startsWith(REFS_GROUPNAMES)
+ || ref.startsWith(REFS_USERS)
+ || ref.startsWith(REFS_STARRED_CHANGES)
+ || ref.startsWith(REFS_REJECT_COMMITS);
+ }
+
static Integer parseShardedRefPart(String name) {
if (name == null) {
return null;