Gerrit Batch Abandon

Gerrit Batch Abandon

from: http://www.mediawiki.org/wiki/Gerrit/mass_approval

We might sometime have to generates a ton of changes. For example when doing a similar change on all our repository.
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`; do gerrit approve --verified 1 --code-review 2 --submit $i; done ;

from: http://gerrit-documentation.googlecode.com/svn/Documentation/2.3/cmd-review.html

Approve the change with commit c0ff33 as “Verified +1”

$ ssh -p 29418 review.example.com gerrit review --verified +1 c0ff33
Append the message “Build Successful”. Notice two levels of quoting is required, one for the local shell, and another for the argument parser inside the Gerrit server:

$ ssh -p 29418 review.example.com gerrit review -m '"Build Successful"' c0ff33
Mark the unmerged commits both “Verified +1” and “Code Review +2” and submit them for merging:

$ ssh -p 29418 review.example.com gerrit review \
--verified +1 \
--code-review +2 \
--submit \
--project this/project \
$(git rev-list origin/master..HEAD)

Abandon an active change:

$ ssh -p 29418 review.example.com gerrit review --abandon c0ff33

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.