Gerrit Comment On Behalf Of

165 views
Skip to first unread message

pian...@gmail.com

unread,
Jul 13, 2023, 3:57:06 PM7/13/23
to Repo and Gerrit Discussion
Hello -

My team supports a separate review tool that is sort of integrated with Gerrit.  People can add and reply to inline comments via either the Gerrit UI or via this separate tool and things are synced between then.  However, when comments/replies are added via this separate tool, the tool uses the Gerrit REST API to add the comment/reply to Gerrit and when people view that new comment/reply in Gerrit, it looks like it was added by the service account that we use to call the REST API and not by the person who actually made the comment. 

Is there a way to add a comment on behalf of another user?  There are ways to provide votes and do some other things on behalf of other users so I was hoping there would be a way to add comments on behalf of other users too, but I was unable to find a way based on the documentation.

Nasser Grainawi

unread,
Jul 24, 2023, 6:44:40 PM7/24/23
to pian...@gmail.com, Repo and Gerrit Discussion
You should be able to do this with the Run As capability and the appropriate header in your REST API requests. See https://gerrit-review.googlesource.com/Documentation/access-control.html#capability_runAs for more info. 

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/bd026620-af29-4cd6-b5b8-8584410799ddn%40googlegroups.com.

Edwin Kempin

unread,
Jul 25, 2023, 6:29:30 AM7/25/23
to Nasser Grainawi, pian...@gmail.com, Repo and Gerrit Discussion
On Tue, Jul 25, 2023 at 12:44 AM Nasser Grainawi <nasser....@linaro.org> wrote:


On Thu, Jul 13, 2023 at 1:57 PM pian...@gmail.com <pian...@gmail.com> wrote:
Hello -

My team supports a separate review tool that is sort of integrated with Gerrit.  People can add and reply to inline comments via either the Gerrit UI or via this separate tool and things are synced between then.  However, when comments/replies are added via this separate tool, the tool uses the Gerrit REST API to add the comment/reply to Gerrit and when people view that new comment/reply in Gerrit, it looks like it was added by the service account that we use to call the REST API and not by the person who actually made the comment. 

Is there a way to add a comment on behalf of another user?  There are ways to provide votes and do some other things on behalf of other users so I was hoping there would be a way to add comments on behalf of other users too, but I was unable to find a way based on the documentation.

You should be able to do this with the Run As capability and the appropriate header in your REST API requests. See https://gerrit-review.googlesource.com/Documentation/access-control.html#capability_runAs for more info. 

The Set Review REST endpoint [1], that can be used to post comments, supports on behalf of (see field on_behalf_of in ReviewInput [2]).


--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/repo-discuss/bd026620-af29-4cd6-b5b8-8584410799ddn%40googlegroups.com.

--
--
To unsubscribe, email repo-discuss...@googlegroups.com
More info at http://groups.google.com/group/repo-discuss?hl=en

---
You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.

Nasser Grainawi

unread,
Jul 25, 2023, 7:10:43 PM7/25/23
to Edwin Kempin, pian...@gmail.com, Repo and Gerrit Discussion
On Tue, Jul 25, 2023 at 4:29 AM Edwin Kempin <eke...@google.com> wrote:


On Tue, Jul 25, 2023 at 12:44 AM Nasser Grainawi <nasser....@linaro.org> wrote:


On Thu, Jul 13, 2023 at 1:57 PM pian...@gmail.com <pian...@gmail.com> wrote:
Hello -

My team supports a separate review tool that is sort of integrated with Gerrit.  People can add and reply to inline comments via either the Gerrit UI or via this separate tool and things are synced between then.  However, when comments/replies are added via this separate tool, the tool uses the Gerrit REST API to add the comment/reply to Gerrit and when people view that new comment/reply in Gerrit, it looks like it was added by the service account that we use to call the REST API and not by the person who actually made the comment. 

Is there a way to add a comment on behalf of another user?  There are ways to provide votes and do some other things on behalf of other users so I was hoping there would be a way to add comments on behalf of other users too, but I was unable to find a way based on the documentation.

You should be able to do this with the Run As capability and the appropriate header in your REST API requests. See https://gerrit-review.googlesource.com/Documentation/access-control.html#capability_runAs for more info. 

The Set Review REST endpoint [1], that can be used to post comments, supports on behalf of (see field on_behalf_of in ReviewInput [2]).

Thanks for sharing that Edwin, I didn't realize that on_behalf_of affects the message as well as the label vote. Does on_behalf_of apply to the entire ReviewInput?

Edwin Kempin

unread,
Jul 26, 2023, 2:17:18 AM7/26/23
to Nasser Grainawi, pian...@gmail.com, Repo and Gerrit Discussion
On Wed, Jul 26, 2023 at 1:10 AM Nasser Grainawi <nasser....@linaro.org> wrote:


On Tue, Jul 25, 2023 at 4:29 AM Edwin Kempin <eke...@google.com> wrote:


On Tue, Jul 25, 2023 at 12:44 AM Nasser Grainawi <nasser....@linaro.org> wrote:


On Thu, Jul 13, 2023 at 1:57 PM pian...@gmail.com <pian...@gmail.com> wrote:
Hello -

My team supports a separate review tool that is sort of integrated with Gerrit.  People can add and reply to inline comments via either the Gerrit UI or via this separate tool and things are synced between then.  However, when comments/replies are added via this separate tool, the tool uses the Gerrit REST API to add the comment/reply to Gerrit and when people view that new comment/reply in Gerrit, it looks like it was added by the service account that we use to call the REST API and not by the person who actually made the comment. 

Is there a way to add a comment on behalf of another user?  There are ways to provide votes and do some other things on behalf of other users so I was hoping there would be a way to add comments on behalf of other users too, but I was unable to find a way based on the documentation.

You should be able to do this with the Run As capability and the appropriate header in your REST API requests. See https://gerrit-review.googlesource.com/Documentation/access-control.html#capability_runAs for more info. 

The Set Review REST endpoint [1], that can be used to post comments, supports on behalf of (see field on_behalf_of in ReviewInput [2]).

Thanks for sharing that Edwin, I didn't realize that on_behalf_of affects the message as well as the label vote. Does on_behalf_of apply to the entire ReviewInput?

AFAIK the on behalf of user is used for creating change messages, comments and approvals and is recorded as author of the NoteDb commit.
I guess this covers the entire ReviewInput.

Note that the real user is recorded as realAuthor/realAuthorId in ChangeMessage, Comment and PatchSetApproval, and as reflog identity for creating commits.
Reply all
Reply to author
Forward
0 new messages