Gerrit lib module to allow filtering out refs in the Git advertizing protocol phase

Clone this repo:
  1. 62e0be5 Filter out edit refs by Luca Milanesio · 9 days ago master
  2. 59e701d Reuse existing Repository for refs filtering by Luca Milanesio · 9 days ago
  3. 770f3a5 Filter out non-existent changes from advertised refs by Luca Milanesio · 10 days ago stable-3.2
  4. e897222 Rely on Gerrit change_notes cache for filtering by Luca Milanesio · 10 days ago
  5. 23cc86c Adjust to core moving to List interface for ref filtering by David Ostrovsky · 1 year, 8 months ago

Git Ref filter module for Gerrit

Gerrit lib module to allow filtering out refs in the Git advertizing protocol phase.

How to build

Build this module as it was a Gerrit plugin:

  • Clone Gerrit source tree
  • Clone the git-refs-filter source tree
  • Link the git-refs-filter directory to Gerrit /plugins/git-refs-filter
  • From Gerrit source tree run bazel build plugins/git-refs-filter
  • And for running tests bazel test plugins/git-refs-filter:git_refs_filter_tests
  • The git-refs-filter.jar module is generated under /bazel-genfiles/plugins/git-refs-filter/

How install

Copy git-refs-filter.jar library to Gerrit /lib and add the following one extra settings to gerrit.config:

[gerrit]
  installModule = com.googlesource.gerrit.modules.gitrefsfilter.RefsFilterModule

How to configure filtering

The refsfilter module defines a new global capability called “Filter out closed changes refs”. By default the capability isn't assigned to any user or group, thus the module installation has no side effects.

Filtering a closed change refs has the following meaning:

  • Merged changes and all their patch-sets
  • Abandoned changes and all their patch-sets
  • Corrupted changes and all their patch-sets
  • All ‘/meta’ refs of all changes
  • All non-published edits of any changes

To enable a group of users of getting a “filtered list” of refs (e.g. CI jobs):

  • Define a new group of users (e.g. Builders)
  • Add a user to that group (e.g. Add ‘jenkins’ to the Builders group)
  • Go to the All-Projects ACLs, add the “Filter out closed changes refs” and assign to the group (e.g. Builders)

NOTE Gerrit makes a super-simplified ACL evaluation if all the projects are globally readable (e.g. project has a READ rule to refs/*). To enable the closed changes filtering you need to disable any global read rule for the group that needs refs filtering.