Gerrit/Navigation: Difference between revisions

From mediawiki.org
Content deleted Content added
→‎Reports: +Simple code review stats, all time and last month
Line 31: Line 31:
* [[../Reports/Merged changesets wed to unresolved bugs|Merged changesets wed to unresolved bugs]]
* [[../Reports/Merged changesets wed to unresolved bugs|Merged changesets wed to unresolved bugs]]
* [[../Reports/Changesets by project|Changesets by project]]
* [[../Reports/Changesets by project|Changesets by project]]
<section begin=crstats />

* Simple code review stats, all time and last month (based on [https://gerrit.googlesource.com/plugins/reviewnotes/+/HEAD/src/main/resources/Documentation/refs-notes-review.md refs/notes/review], containing only CodeReview votes for the last patchset of each commit)
** [[tools:~nemobis/crstats/core.txt|MediaWiki core]]
** [[tools:~nemobis/crstats/extensions.txt|MediaWiki extensions]]
<section end=crstats />
; Source
; Source
* https://github.com/mzmcbride/gerrit-reports
* https://github.com/mzmcbride/gerrit-reports

Revision as of 12:40, 6 July 2013

Gerrit's interface can be difficult to navigate for those new to the tool. The following documentation can help newcomers learn how to navigate Gerrit.

Browsing projects

To view all projects in gerrit, go to Projects > List.

Clicking a project name in that list doesn't give you much useful information, but then you can go to Project > Branches and click the gitweb link for the "master" branch. In gitweb then click the " | tree" link at the top of the list of commits to actually see WTF is in the project. Clicking the "blob" or "raw" link next to a file name will finally show you some code.

The core MediaWiki source code is in project "mediawiki/core", browse away. In general you want to view the HEAD or master branch. If you want to look at the code for the version of MediaWiki or an extension deployed on some wiki, visit that wiki's Special:Version page and look for a corresponding branch or commit.

Search

The search bar is powerful, but requires keywords. Here you can find the list of these keywords.

If you enter the e-mail address of a Gerrit participant, you'll see a list of his or her activity.

Code inspection

Usually the underlying code can be found through a "gitweb" or "tree" link, either of which will take you to the Gitweb interface. These links aren't prominently displayed, though. You can find links to gitweb on every change, next to the "Patch Set" fields. You can also access gitweb directly for each project by URL: https://gerrit.wikimedia.org/r/gitweb?p=<project.name>.git

Reports

Updated daily
Source
Resources
Scripts and other reports

Gerrit queries

You can run queries against gerrit from the command line. You connect over ssh to execute commands of the form gerrit query ' query parameters ' on the gerrit host.

Commits lists

You can use gerrit query to get a list of commits based on several parameters, see documentation; search operators are the same as in the web interface, with some differences and more sugar. It requires developer access.

This will give a list of unreviewed commits:

ssh -p 29418 <username>@gerrit.wikimedia.org gerrit query 'status:open project:^mediawiki/.* AND NOT label:Code-Review<=-1'

To show only the count of unreviewed commits, append | grep rowCount.

For a list of commits to all MediaWiki repos which have been, or need to be, reviewed by a user (Brion in this example):

ssh -p 29418 <username>@gerrit.wikimedia.org gerrit query 'project:^mediawiki/.* reviewer:brion AND NOT owner:L10n-bot'

it excludes the L10n-bot which sometimes alters the results.

You can define a "review" shortcut in your ssh configuration so that you don't have to enter the full username@gerrit.wikimedia.org each time, see Gerrit/Advanced usage#Setup SSH shortcut (optional)

Counts by user

To get more lists/counts, you can use a simple for loop and grep in a bash script, like this:

#!/bin/bash

for name in aaron agarrett arichards bawolff+wn bjorsch brion catrope csteipp daniel.kinzler danwe demon gwicke hartman.wiki hashar ialex jeroendedauw krinkle maxsem.wiki ngautam nikerabbit ori platonides preilly raimond.spekking reedy rfaulkner rkaldari robinp.1273 robla siebrand sumanah tchay tfinc tobias.gritschacher tparscal tstarling vasilvv
do 
  echo $name is owner: and reviewer: of: ;
  ssh -p 29418 <username>@gerrit.wikimedia.org gerrit query "project:^mediawiki/.* owner:$name AND NOT reviewer:$name" | grep rowCount ; 
  ssh -p 29418 <username>@gerrit.wikimedia.org gerrit query "project:^mediawiki/.* reviewer:$name AND NOT owner:$name AND NOT owner:L10n-bot" | grep rowCount ; 
  echo ; 
done

In the example we generate some code commits and code review stats for the "mediawiki" group members and other top contributors according to Ohloh (excluding self-merges which are by definition not CR and also most likely minor commits); the output is something like this.

System messages

If you need to ask documentation or other info about a system message (e.g. for translatewiki:Support), it's not that easy to find the correct person. Gerrit and gitweb are useless to this purpose, but here's what you can do:

Look who introduced or modified the message in core: go to your checkout of the code and do, for instance:

core$ git blame languages/messages/MessagesEn.php | grep clearyourcache
11c51c3f languages/messages/MessagesEn.php (Leo Koppelkamm        2011-07-07 15:59:42 +0000 1377) 'clearyourcache'                   => "'''Note:''' After saving, you may have to bypass your browser's cache to see the changes.

To find the previous committer:

core$ git blame 11c51c3f^ languages/messages/MessagesEn.php | grep clearyourcache
8cf03e76 languages/messages/MessagesEn.php (Siebrand Mazeland     2010-01-16 17:44:18 +0000 1320) 'clearyourcache'                   => "'''Note: After saving, you may have to bypass your browser's cache to see the changes.'''

With an extension you have to do the same on its i18n template and restrict to the first result (English); if you don't know what extension or what file to check, you'll have to grep -r or ack the whole directory (git-blame'ing all the repositories at once is not trivially possible, you'd need to use a script or some find magic to walk through the directories and set the git path).

extensions/MoodBar$ git blame MoodBar.i18n.php | grep -m 1 moodbar-what-content
e2ceb863 MoodBar.i18n.php (Siebrand Mazeland       2011-08-02 10:20:49 +0000   47)      'moodbar-what-content' => 'This feature is designed to help the community understand the experience of people editing the site.

Now, at last, you have the hash for the change and you can look for it on gerrit or, if it's too old/not in git review, you can use git show to get contact info.

Otherwise, a safe bet might be the most (recently) active dev of the extension: go to its repository and get a list of the authors with most commits and their email addresses (@users.mediawiki.org are fake addresses):

extensions/MoodBar$ git shortlog -se
     1  Aaron Schulz <aaron@users.mediawiki.org>
    10  Alexandre Emsenhuber <ialex@users.mediawiki.org>
[...]

Of course you can as well file a bug on bugzilla (if there's the correct component), or on the talk page of the extension or of its maintainer (if the wiki is up to date) and just wait...