Owen
Owen

Reputation: 1

Does Gerrit have an owner for each branch?

I am setting up Gerrit in an on-premise environment and conducting various tests. I have a question regarding the commit & push permissions on Gerrit branches.

Does Gerrit have an owner for each branch?

I was performing code review tests by committing & pushing to the X branch with user B information. However, when I tried to commit & push with user A information, I received an error message stating that I don't have the 'Forge Committer' permission, and I couldn't proceed with the commit & push. So, I granted A the "Forge Committer Identity" permission for refs/for/*.

After granting this permission, I committed & pushed to the X branch with user A's information and created a code review. However, the owner of the code review is set to B, and A is automatically designated as the Author of the review.

I'm curious why this automatic assignment is happening.

Upvotes: 0

Views: 284

Answers (1)

ElpieKay
ElpieKay

Reputation: 30888

The owner you see is the owner of the change, not of the target branch. You run git push origin HEAD:refs/for/foo to upload the latest patch set of the change. In the command, origin refers to a URL of either SSH protocol or HTTP/HTTPS protocol. Both need authentication. SSH uses a pair of keys and HTTP/HTTPS uses a username and password/token. The keys or the username is associated with a Gerrit username. The Gerrit username will be the owner of the change.

Gerrit checks the committer email in the new commit. If it does not match any of the emails registered in the Gerrit username, and if the username does not have the Forge Committer permission, the push is rejected. To some extent, it prevents one user from faking another user.

If you want A to be the owner, you need to use the authentication associated with A's Gerrit username in git push.

git push ssh://${UsernameOfA}@${gerrithost}:${port}/${reponame} HEAD:refs/for/foo
# Or
git push https://${UsernameOfA}:${password}@${gerrithost}/${reponame} HEAD:refs/for/foo

Upvotes: 1

Related Questions