Wikimedia Developer Support

Writing a bot that gives CR+2 on gerrit


There are some bots that apply changes to repos in gerrit and afterwards git a CR+2 to their changes (e.g. ‘libraryupgrader’, ‘translatewiki’, …).

I’ve found the following implementation:

But when I try to run

git push origin refs/for/REL1_31%topic=Some_topic_branch,l=Code-Review+2


git push ssh:// refs/for/REL1_31%topic=Some_topic_branch,l=Code-Review+2

I receive

remote: Processing changes: refs: 1, done            
To ssh://
 ! [remote rejected] HEAD -> refs/for/REL1_31%topic=Some_topic_branch,l=Code-Review+2 (no new changes)

I would have expected to run into a permission issue because my user may not be allowed to push, but this error message suggests something else.

Can anyone give me an advice please?


Normally you get that error when you have already pushed the changeset earlier and the version you are trying to push now is identical to the version on Gerrit.


Thanks! Yes, this is true. I thought it’s a two step process:

  1. execute git review in the repo to create the review in gerrit

  2. execute git push origin refs/for/REL1_31%topic=Some_topic_branch,l=Code-Review+2 in the repo to vote +2 on Code Review

Do I need to reset my changes (git reset --hard origin/REL1_31) or switch to the base branch (git checkout REL1_31) before step 2?


To me it seems you have already pushed the change with git review and then push again with the second command. The second command is probably enough alone, or if you do it in two steps, the vote command needs to be done differently (compare with L10n-bot code).


Indeed, Gerrit does everything with normal git commands (it pretends to be a remote repository you can push commits to), git review is just a human-friendly wrapper around those commands. (And a third-party one at that, it’s maintained by the Openstack community, not the Gerrit developers.) So it would do the same refs/for/... push, except I don’t think git review supports setting review flags during the push.

Gerrit has pretty good documentation (git-review not so much…), see Uploading Changes # git push for details.


Thanks for all your input! I believe I will do something like this

  1. execute git review in the repo to create the review in gerrit

  2. extract commit-id (e.g. 57a937f2)

  3. execute ssh -p 29418 gerrit review 57a937f2 --code-review 2 [1]

This is basically what the L10n-bot script does that @Nikerabbit pointed to. Did not test it yet, but it sounds promising. Thanks again!



Just tested it. Works. Thanks to all.