Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I list all comments posted on my changes in gerrit?

Tags:

git

gerrit

Here and there, colleague leaves a comment on my code changes which I post in gerrit. However to see them I have to:

  • click on the gerrit change in the list of changes. This link does not even indicate whether anything was commented
    image description
  • Then see a list of files and click on any that has something in the Comments column
    image description
  • Then I can read the comment

It would be much better to see a list of code fragments which have comments, sorted by time. That way, I wouldn't have to click all over my edit history.

How do I list all comments posted on my changes in gerrit?

like image 577
Tomáš Zato - Reinstate Monica Avatar asked Jan 17 '17 13:01

Tomáš Zato - Reinstate Monica


1 Answers

You could try to use REST to retrive this kind of info.

1) To list all open changes created by you:

curl -s --request GET --netrc https://GERRIT-SERVER/a/changes/?q=owner:self+AND+status:open | sed 1d | jq --raw-output ".[] | ._number"

2) To list all comments (and their dates) on a change:

curl -s --request GET --netrc https://GERRIT-SERVER/a/changes/CHANGE-NUMBER/comments | sed 1d | jq --raw-output ".[] | .[] | {Updated: .updated, Message: .message}"

Doing 1 + 2:

for c in $(curl -s --request GET --netrc https://GERRIT-SERVER/a/changes/?q=owner:self+AND+status:open | sed 1d | jq --raw-output ".[] | ._number")
do
    curl -s --request GET --netrc https://GERRIT-SERVER/a/changes/$c/comments | sed 1d | jq --raw-output ".[] | .[] | {Updated: .updated, Message: .message}"
done
like image 67
Marcelo Ávila de Oliveira Avatar answered Sep 17 '22 18:09

Marcelo Ávila de Oliveira