How to merge commit in Gerrit Code Review

27,579

Solution 1

I resolved my issue.

Pay attention to 3 categories on Admin/Project/Access:

  • CodeReview
  • Verified
  • Submit

I miss the 2 last categories, so, Gerrit don't show the submit button

Solution 2

Once a commit has the maximum score in each category and no minimum scores in any category, it can be merged. The default categories are Code Review (-2 to +2) and Verified (-1 to +1). So to merge a commit, it must have a +2 Code Review and +1 Verified score, and no -2 Code Review or -1 Verified scores.

A user with 'Submit' privileges will see the 'Submit Patch Set n' button next to the 'Review' button. Click it to merge the commit.

Solution 3

The default permissions in Gerrit are not always what you might expect. In order for the first reviewer to be able to submit the review, you will have to give them (well, Administrators) permission to do a "+2" review score.

After you do this and the reviewer marks the commit as +2, then Gerrit will automatically merge the commit into the branch for which it was submitted.

Share:
27,579
vietstone
Author by

vietstone

Updated on July 05, 2022

Comments

  • vietstone
    vietstone almost 2 years

    I'm newbie to gerrit: http://code.google.com/p/gerrit/ I installed it with git on my local Mac. It's done.

    I make some test action:

    • register 2 accounts, the first accounts grant the "Administrators" privilege, the second account grant the "Registered Users"

    • create new project

    • I use the second account to push an commit to master branch for review. Add the first as reviewer

    • Review is OK. How to merge this commit to main branch? Any solution by web UI?

    Thank you!

  • vietstone
    vietstone over 12 years
    Hi, I mark as +2. It only show the message "Looks good to me, approved". The code is not merged.
  • Greg Hewgill
    Greg Hewgill over 12 years
    Did you press the "Submit" button after marking as +2? That is what tells Gerrit to perform the merge.
  • vietstone
    vietstone over 12 years
    I don't see the button "Submit"
  • vietstone
    vietstone over 12 years
    Can you give me the screenshot of it?
  • Greg Hewgill
    Greg Hewgill over 12 years
    Not today, because my installation of Gerrit is at work, and I'm not. But here's the part of the documentation that shows the "Submit" permission: gerrit-documentation.googlecode.com/svn/Documentation/2.2.0/‌​…
  • akostadinov
    akostadinov over 8 years
    for whoever struggles with that, it seems like +2 review and +1 verify is necessary for a submit button to appear
  • Wildcard
    Wildcard almost 6 years
    When you say it "automatically merges," does it in fact merge as in creating a merge commit (with two parents)? Or does it just apply the change as in creating one ordinary git commit (one parent) incorporating all the changes that have been reviewed? (This gist describing gerrit seems to imply the latter.)
  • Greg Hewgill
    Greg Hewgill almost 6 years
    @Wildcard: What you're describing (as "applying" the change) is called a "fast-forward merge" in Git. It's still a merge, but without the two-parent merge commit.
  • Wildcard
    Wildcard almost 6 years
    @GregHewgill, got it. But, if the master branch has been committed to between the time the change was made (created) and the time it was submitted (applied/merged), does Gerrit still apply it as a fast forward merge in the way that GitLab would call a "rebase, squash and fast forward"? Or does it ever make a merge commit? (Pointers to documentation welcome.)
  • Greg Hewgill
    Greg Hewgill almost 6 years
    @Wildcard: Gerrit can make merge commits too, depending on your situation, how you've set up Gerrit, and how you use branches in your project.