Sazzad Hissain Khan
Sazzad Hissain Khan

Reputation: 40226

How to check if a group was not added in the gerrit CL?

I am working in a large team. We are using Git with Gerrit. To ensure code quality with extensive review system, we have a gerrit group which we want to add for each commit (CL) from each developers, especially for main branch which we need to keep stable. All the reviewers of this group are senior members and they review each CL exclusively. But, some developers merging their CL without adding the group (may be unintentionally) and we cannot know that the CL is merged already. To avoid manual checking, I want to detect if the group was not added (i.e. all group members are not present as reviewers) in the CL. How can I do so?

Is there any API from gerrit which I can use?

Upvotes: 0

Views: 151

Answers (1)

ElpieKay
ElpieKay

Reputation: 30888

With gerrit query, you can get the reviewers of a change:

ssh -p 29418 ${username}@${gerrithost} gerrit query commit:${sha1} --all-reviewers

The reviewers are listed like:

allReviewers:
name: Tom
email: [email protected]
username: tom

You can add --format=json to get the output in json.

I'd suggest you add the group to reviewers automatically in Gerrit's hook, like patch-set-created.

Upvotes: 1

Related Questions