Gerrit/mass approval

We might sometime have to generates a ton of changes. For example when doing a similar change on all our repository. This happened after the MediaWiki extensions got migrated to git since we had to add .gitreview files everywhere.

First, you can query gerrit for a list of change using the CLI! A useful alias:

alias gerrit='ssh -p 29418 gerrit.wikimedia.org gerrit'

Then use that to execute a query such as all open changes on topic dotgitreview: gerrit query 'status:open topic:dotgitreview'

With some shell magic, you can get a list of change number:

gerrit query 'status:open topic:dotgitreview' \ | egrep '^ number' | cut -d\  -f4- > CHANGES_NUMBERS

Then loop on them and remotely approve the changes! for i in `cat CHANGES_NUMBERS`; do gerrit review --label Code-Review=2 --submit $i; done

You know what to do with all the profit you have just earned. Give them to your favorite foundation!