Class RefNames


  • public class RefNames
    extends Object
    Constants and utilities for Gerrit-specific ref names.
    • Field Detail

      • REFS_REJECT_COMMITS

        public static final String REFS_REJECT_COMMITS
        Note tree listing commits we refuse refs/meta/reject-commits
        See Also:
        Constant Field Values
      • REFS_CONFIG

        public static final String REFS_CONFIG
        Configuration settings for a project refs/meta/config
        See Also:
        Constant Field Values
      • REFS_USERS_SELF

        public static final String REFS_USERS_SELF
        Magic user branch in All-Users refs/users/self
        See Also:
        Constant Field Values
      • REFS_DASHBOARDS

        public static final String REFS_DASHBOARDS
        Configurations of project-specific dashboards (canned search queries).
        See Also:
        Constant Field Values
      • REFS_CACHE_AUTOMERGE

        public static final String REFS_CACHE_AUTOMERGE
        Prefix applied to merge commit base nodes.

        References in this directory should take the form refs/cache-automerge/xx/yyyy... where xx is the first two digits of the merge commit's object name, and yyyyy... is the remaining 38. The reference should point to a treeish that is the automatic merge result of the merge commit's parents.

        See Also:
        Constant Field Values
      • ROBOT_COMMENTS_SUFFIX

        public static final String ROBOT_COMMENTS_SUFFIX
        Suffix of a ref that stores robot comments in the NoteDb.
        See Also:
        Constant Field Values
      • REFS_GROUPNAMES

        public static final String REFS_GROUPNAMES
        NoteDb ref for the NoteMap of all group names
        See Also:
        Constant Field Values
      • REFS_DELETED_GROUPS

        public static final String REFS_DELETED_GROUPS
        NoteDb ref for deleted groups refs/deleted-groups. This ref namespace is foreseen as an attic for deleted groups (it's reserved but not used yet)
        See Also:
        Constant Field Values
      • REFS_DRAFT_COMMENTS

        public static final String REFS_DRAFT_COMMENTS
        Draft inline comments of a user on a change
        See Also:
        Constant Field Values
      • GERRIT_REFS

        public static final com.google.common.collect.ImmutableList<String> GERRIT_REFS
        List of refs managed by Gerrit. Covers all Gerrit internal refs.

        Caution Any ref not in this list will be served if the user was granted a READ permission on it using Gerrit's permission model.

    • Method Detail

      • shortName

        public static final String shortName​(String ref)
      • changeMetaRef

        public static String changeMetaRef​(Change.Id id)
        Warning: Change refs have to manually be advertised in com.google.gerrit.server.permissions.DefaultRefFilter; this should be done when adding new change refs.
      • robotCommentsRef

        public static String robotCommentsRef​(Change.Id id)
      • isNoteDbMetaRef

        public static boolean isNoteDbMetaRef​(String ref)
      • isRefsChanges

        public static boolean isRefsChanges​(String ref)
        True if the provided ref is in refs/changes/*.
      • isSequenceRef

        public static boolean isSequenceRef​(String ref)
        True if the provided ref is in refs/sequences/*.
      • isTagRef

        public static boolean isTagRef​(String ref)
        True if the provided ref is in refs/tags/*.
      • isExternalIdRef

        public static boolean isExternalIdRef​(String ref)
        True if the provided ref is REFS_EXTERNAL_IDS.
      • refsDraftCommentsPrefix

        public static String refsDraftCommentsPrefix​(Change.Id changeId)
      • refsStarredChangesPrefix

        public static String refsStarredChangesPrefix​(Change.Id changeId)
      • refsCacheAutomerge

        public static String refsCacheAutomerge​(String hash)
      • shard

        public static String shard​(int id)
      • shardUuid

        public static String shardUuid​(String uuid)
      • refsEdit

        public static String refsEdit​(Account.Id accountId,
                                      Change.Id changeId,
                                      PatchSet.Id psId)
        Returns reference for this change edit with sharded user and change number: refs/users/UU/UUUU/edit-CCCC/P.
        Parameters:
        accountId - account id
        changeId - change number
        psId - patch set number
        Returns:
        reference for this change edit
      • refsEditPrefix

        public static String refsEditPrefix​(Account.Id accountId,
                                            Change.Id changeId)
        Returns reference prefix for this change edit with sharded user and change number: refs/users/UU/UUUU/edit-CCCC/.
        Parameters:
        accountId - account id
        changeId - change number
        Returns:
        reference prefix for this change edit
      • refsEditPrefix

        public static String refsEditPrefix​(Account.Id accountId)
      • isRefsEdit

        public static boolean isRefsEdit​(String ref)
      • isRefsUsers

        public static boolean isRefsUsers​(String ref)
      • isRefsUsersSelf

        public static boolean isRefsUsersSelf​(String ref,
                                              boolean isAllUsers)
      • isRefsGroups

        public static boolean isRefsGroups​(String ref)
        Whether the ref is a group branch that stores NoteDb data of a group. Returns true for all refs that start with refs/groups/.
      • isRefsDeletedGroups

        public static boolean isRefsDeletedGroups​(String ref)
        Whether the ref is a group branch that stores NoteDb data of a deleted group. Returns true for all refs that start with refs/deleted-groups/.
      • isRefsDraftsComments

        public static boolean isRefsDraftsComments​(String ref)
        Returns true if the provided ref is for draft comments.
      • isRefsStarredChanges

        public static boolean isRefsStarredChanges​(String ref)
        Returns true if the provided ref is for starred changes.
      • isGroupRef

        public static boolean isGroupRef​(String ref)
        Whether the ref is used for storing group data in NoteDb. Returns true for all group branches, refs/meta/group-names and deleted group branches.
      • isConfigRef

        public static boolean isConfigRef​(String ref)
        Whether the ref is the configuration branch, i.e. refs/meta/config, for a project.
      • isVersionRef

        public static boolean isVersionRef​(String ref)
        Whether the ref is the version branch, i.e. refs/meta/version.
      • isAutoMergeRef

        public static boolean isAutoMergeRef​(String ref)
        Whether the ref is an auto-merge ref.
      • isRejectCommitsRef

        public static boolean isRejectCommitsRef​(String ref)
        Whether the ref is an reject commit ref, i.e. refs/meta/reject-commits
      • isGerritRef

        public static boolean isGerritRef​(String 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.

        Any ref for which this method evaluates to true will be served to users who have the ACCESS_DATABASE capability.

        Caution Any ref not in this list will be served if the user was granted a READ permission on it using Gerrit's permission model.

      • parseShardedUuidFromRefPart

        public static String parseShardedUuidFromRefPart​(String name)
      • parseRefSuffix

        public static Integer parseRefSuffix​(String name)