Page MenuHomePhabricator

Enable Gerrit reviewers-by-blame plugin
Closed, DeclinedPublic


Per discussion in T91190, it would be nice to enable reviewers-by-blame which helps inexperienced developers find the right person for code review.
(I'm not sure what the roadmap is for Gerrit -> Phabricator migration - please decline if it's too close for Gerrit improvements to be worth the effort. Closest Phabricator equivalent I have found is phabricator:T1743, still under development.)

Event Timeline

Tgr raised the priority of this task from to Needs Triage.
Tgr updated the task description. (Show Details)
Tgr added a project: Gerrit.
Tgr added a subscriber: Tgr.

This project is selected for the Developer-Wishlist voting round and will be added to a MediaWiki page very soon. To the subscribers, or proposer of this task: please help modify the task description: add a brief summary (10-12 lines) of the problem that this proposal raises, topics discussed in the comments, and a proposed solution (if there is any yet). Remember to add a header with a title "Description," to your content. Please do so before February 5th, 12:00 pm UTC.

This will have to be written for polygerrit's ui since gwtui has begun to be removed upstream. We can still make it for gwtui but it will need to support polygerrit ui too.

Change 422178 had a related patch set uploaded (by Chad; owner: Chad):
[operations/software/gerrit/gerrit@wmf/stable-2.14] Adding reviewers-by-blame plugin

Change 422178 merged by Chad:
[operations/software/gerrit/gerrit@wmf/stable-2.14] Adding reviewers-by-blame plugin

We have the plugin installed: as well as the reviewer one

Both can be configured on a per project basis by the project owners. Ideally one would want to craft a tutorial/example, highlight it via a Phame post / wikitech-l then I guess we can call it done.

The plugin is enabled. On All-Projects there are some configuration bits available:

reviewers-by-blame Plugin

Ignore file Regex: ____________
[Ignore files that match the given regular expression when looking for reviewers]

Ignore Regex: ____________
[Ignore commits where the subject matches the given regular expression]

Max Reviewers: 3
[The maximum number of reviewers that should be automatically added to a change based on the git blame computation on the changed files.]

So it should work? Unless there is some magic flag required.

I have send a patch to restore logging of plugins at INFO level with , that might give us some clues. Then if haven't figured it out yet, we can add a log4j debug logger for com.googlesource.gerrit.plugins.reviewersbyblame. enables logging for plugins:

[2018-11-28 16:57:47,182] [main] INFO  : Loaded plugin reviewers-by-blame, version 2c08ef7

Will probably need to be tweaked to use DEBUG level for the reviewersbyblame plugin (see above), will let us figure out whether it works properly.

Change 476343 had a related patch set uploaded (by Hashar; owner: Hashar):
[operations/puppet@production] gerrit: log reviewers-by-blame plugin at DEBUG level

Change 476343 abandoned by Hashar:
gerrit: log reviewers-by-blame plugin at DEBUG level

Bah actually the code only has log entries for warn or error ...

I assume that is already logged by the root logger.

Does not seem to be working, my list of reviewer suggestions seems to be populated from people I asked for a review in the past, and is not specific to the repo. E.g. here is a random extension: BlueSpiceExtendedFilelist, you can see that the top reviewer is Robert Vogel. But when I click on "add reviewer" I get a list of people who have never even interacted with that repo, and as far as I can see the only common feature is that they have all reviewed patches of mine in the past, and that I have asked all of them for a review at some point in time in some repo (but not BlueSpiceExtendedFilelist).

Mentioned in SAL (#wikimedia-operations) [2019-01-08T09:19:39Z] <hashar> gerrit: resaved configuration for All-Projects by changing "Max Reviewers" from 3 to 4. Might enable adding reviewers automatically based on git blame. See task for config diff # T101131

Indeed it is definitely not adding reviewers. That puzzled me during the xmas break and eventually had an idea this morning. Based on my previous comment about the plugin configuration ( T101131#4766853 ) I eventually looked at the raw configuration file on the project:

$ git clone
$ git fetch refs/meta/config && git checkout FETCH_HEAD
$ grep -i reviewer project.config

Ie despite the UI showing some values, there are none listed in the All-Projects configuration. In the web UI I have thus changed Max Reviewers from 3 to 4 (using copy paste since my browser/javascript would not let me add a value). I have saved the config b972f5ea571e7bd15542a6562dd1d0b010681a1a which got me:

$ git fetch refs/meta/config
$ git reset --hard FETCH_HEAD
$ git show
commit b972f5ea571e7bd15542a6562dd1d0b010681a1a
Author: Hashar <>
Date:   Tue Jan 8 09:17:04 2019 +0000

    Modified project settings

diff --git a/project.config b/project.config
index fa884eb..85399de 100644
--- a/project.config
+++ b/project.config
@@ -51,6 +51,7 @@
        mergeContent = false
        action = fast forward only
+       matchAuthorToCommitterDate = false
        default = refs/meta/dashboards/default:recent
 [label "Verified"]
@@ -90,5 +91,12 @@
        push = group Administrators
        push = group Gerrit Managers
        push = group Project Owners
+       privateByDefault = false
+       workInProgressByDefault = false
+       enableByEmail = false
+[plugin "reviewers-by-blame"]
+       maxReviewers = 4
 [plugin "its-phabricator"]
        enabled = true

Which is b972f5ea571e7bd15542a6562dd1d0b010681a1a. Some settings are just normalization. The code default to 3 anyway via a getInt("maxReviewers", 3). So I dont see how my change could modify anything.

Note the plugin is definitely installed and loaded based on

Eventually I have found reviewers-by-blame on stable-2.15 busted with NoteDb. It points at Change 192110: Find change via ChangeData.Factory rather than ReviewDb.

Git log:

* 0b6233e - (origin/stable-2.15) Find change via ChangeData.Factory rather than ReviewDb (8 weeks ago) <Richard Christie>
| * 5ff127d - (origin/master, origin/HEAD) Adapats plugin to changes done in core (3 months ago) <Paladox none>
| * d2fc6d7 - Adapt to new core package layout (1 year, 2 months ago) <Paladox none>
* 2c08ef7 - (HEAD -> master) Adapt to removed AccountByEmailCache (1 year, 2 months ago) <Paladox none>
* 85abed9 - Remove support for drafts (1 year, 2 months ago) <Paladox none>
* 7daadf5 - (origin/stable-2.14) Format all Java files with google-java-format (1 year, 2 months ago) <David Pursehouse>

So we need to update our copy of reviewers-by-blame from 2c08ef7 to stable-2.15 and we will get the change.

Change 482775 had a related patch set uploaded (by Hashar; owner: Hashar):
[operations/software/gerrit@wmf/stable-2.15] Update plugins reviewers-by-blame to stable-2.15

From @thcipriani to rebuild the plugin one would do something like:

bazel build plugins/reviewers-by-blame
bazel build plugins/reviewers-by-blame:reviewers-by-blame

Result in bazel-bin

Upload the resulting .jar to Archiva, update git fat (we have a script to handle that: upload-artifacts script).

Then scap deploy. We don't even need to restart Gerrit.

I went with install bazel from their apt package (which is a huge binary blob bah). Then:

$ cd ~/projects/operations/software/gerrit
$ bazel build plugins/reviewers-by-blame:reviewers-by-blame
INFO: Analysed target //plugins/reviewers-by-blame:reviewers-by-blame (142 packages loaded, 3182 targets configured).
INFO: Found 1 target...
Target //plugins/reviewers-by-blame:reviewers-by-blame up-to-date:
INFO: Elapsed time: 44.699s, Critical Path: 12.04s
INFO: 126 processes: 121 processwrapper-sandbox, 5 worker.
INFO: Build completed successfully, 140 total actions

Which gets me a ton of .jar files:

$ find bazel-genfiles/ -type f

Maybe we just need bazel-genfiles/plugins/reviewers-by-blame/reviewers-by-blame.jar

@hashar correct (for the path to the plugin jar)

Change 482775 abandoned by Hashar:
Update plugins reviewers-by-blame to stable-2.15

Superseeded by the upgrade to Gerrit 2.15.8 /484437/

The plugin version we were using was not compatible yet with Gerrit 2.15. In the previous upgrades we forgot to bump the plugin.

With Gerrit 2.15.8 (T210785) which we upgraded a few minutes ago, the plugin got bumped. Looking at a few recent changes, they seem to have magic reviewers being added to change!

I am assuming the plugin works properly now!

Works great, thank you for fixing it!

Given that action of adding reviewers is done under the name of the uploader, so it's not entirely obvious what's going on, maybe a wikitech-l announcement would be in order?
(Or we could just ask upstream to add an option to use a dedicated user for adding reviers.)

Works great, thank you for fixing it!

Given that action of adding reviewers is done under the name of the uploader, so it's not entirely obvious what's going on, maybe a wikitech-l announcement would be in order?
(Or we could just ask upstream to add an option to use a dedicated user for adding reviers.)

We should do both, Email in the short term, but ideally in the long term we should request automated actions like that are done by a system user and not as a actual user when the user isn't actually performing the action.

I have published a blog explaining the Gerrit review by blame plugin as well as other manual way to find reviewers: J139: Blog Post: Gerrit now automatically adds reviewers

ideally in the long term we should request automated actions like that are done by a system user and not as a actual user when the user isn't actually performing the action.

Filed upstream as #10328.

ideally in the long term we should request automated actions like that are done by a system user and not as a actual user when the user isn't actually performing the action.

Filed upstream as #10328.

@Paladox had filed which is similar (exempting bot accounts vs using a dedicated account)

Change 485184 had a related patch set uploaded (by Hashar; owner: Hashar):
[All-Projects@refs/meta/config] reviewers-by-blame: default to not adding any reviewers

As a follow up (also posted as a comment to J139):

The Gerrit plugin blindly adds reviewers even when in a few cases it might not be appropriate (for a bot account, author of code who is not qualified to do a review, user that is no more active on a repository).

As such, the plugin will no more report by default. The configuration setting maxReviewers has been set to 0 in All-Projects.git(Gerrit #485184) which causes the plugin to early abort. The setting is inherited by all repositories

Project owners can still enable the setting for their repository by editing the project settings and setting maxReviewers to a positive integer.

Change 485184 merged by Thcipriani:
[All-Projects@refs/meta/config] reviewers-by-blame: default to not adding any reviewers

Change 485810 had a related patch set uploaded (by Hashar; owner: Thcipriani):
[operations/software/gerrit@deploy/wmf/stable-2.15] Remove reviewers-by-blame from deployment

hashar changed the task status from Resolved to Declined.Jan 22 2019, 2:05 PM

Thank you @Tgr and @Paladox . We are going to uninstall the plugin entirely based on the feedback from the thread wikitech-l Gerrit now automatically adds reviewers.

We would need way more features to be implement before considering enabling it again. Something to take in mind for later is to gradually enable it per repository instead of globally.

I am changing this to Declined, I don't think we will enable it anytime soon. But feel free to flip it to stalled state instead :)

Change 485810 merged by Thcipriani:
[operations/software/gerrit@deploy/wmf/stable-2.15] Remove reviewers-by-blame from deployment

Change 486262 had a related patch set uploaded (by Hashar; owner: Hashar):
[operations/software/gerrit@wmf/stable-2.15] Remove reviewers-by-blame

Change 486262 merged by Thcipriani:
[operations/software/gerrit@wmf/stable-2.15] Remove reviewers-by-blame