Enable Gerrit reviewers-by-blame plugin
Closed, ResolvedPublic


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.)

Tgr created this task.Jun 2 2015, 5:32 PM
Tgr updated the task description. (Show Details)
Tgr raised the priority of this task from to Needs Triage.
Tgr added a project: Gerrit.
Tgr added a subscriber: Tgr.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 2 2015, 5:32 PM
Ricordisamoa added a subscriber: Ricordisamoa.
scfc added a subscriber: scfc.Jun 2 2015, 6:40 PM
Paladox set Security to None.Jun 2 2015, 11:07 PM
Paladox added subscribers: Legoktm, QChris.
hashar triaged this task as Low priority.Sep 10 2015, 9:54 AM
mmodell added a subscriber: mmodell.Jun 2 2016, 7:49 PM
demon moved this task from Bugs & stuff to Needs a plugin! on the Gerrit board.Jul 26 2016, 11:25 PM
Dalba awarded a token.Dec 12 2016, 3:14 AM
Dalba added a subscriber: Dalba.
Paladox updated the task description. (Show Details)Jan 28 2017, 2:11 AM
Paladox added a subscriber: Paladox.

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


hashar added a subscriber: hashar.EditedNov 21 2018, 9:05 PM

We have the plugin installed: https://gerrit.wikimedia.org/r/plugins/reviewers-by-blame/Documentation/index.html as well as the reviewer one https://gerrit.wikimedia.org/r/plugins/reviewers/Documentation/index.html

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 https://gerrit.wikimedia.org/r/#/c/475226/ , 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.

https://gerrit.wikimedia.org/r/#/c/operations/puppet/+/475226/ 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.


Tgr added a comment.Dec 17 2018, 3:59 AM

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

hashar added a comment.Tue, Jan 8, 9:30 AM

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 https://gerrit.wikimedia.org/r/p/All-Projects.git
$ 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 <hashar@free.fr>
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 https://gerrit.wikimedia.org/r/#/admin/plugins/

hashar added a comment.Tue, Jan 8, 9:38 AM

Eventually I have found https://groups.google.com/d/msg/repo-discuss/-5kMTN34aqw/zgTAEgReDgAJ 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


hashar claimed this task.Tue, Jan 8, 9:59 AM
hashar added a subscriber: thcipriani.EditedTue, Jan 8, 4:09 PM

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 https://gerrit.wikimedia.org/r/#/c/operations/software/gerrit/ /484437/


hashar closed this task as Resolved.Wed, Jan 16, 7:52 PM

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!

Tgr awarded a token.Thu, Jan 17, 2:30 AM

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

Tgr added a comment.Thu, Jan 17, 7:58 PM

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.

greg added a subscriber: greg.Thu, Jan 17, 8:01 PM

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 https://bugs.chromium.org/p/gerrit/issues/detail?id=10318 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