Gerrit Batch Abandon

Gerrit Batch Abandon


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'

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 ;


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

$ ssh -p 29418 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 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 gerrit review \
--verified +1 \
--code-review +2 \
--submit \
--project this/project \
$(git rev-list origin/master..HEAD)

Abandon an active change:

$ ssh -p 29418 gerrit review --abandon c0ff33

Leave a Reply

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