gerrit-cli icon indicating copy to clipboard operation
gerrit-cli copied to clipboard

Did you came out with any solution to add inline comments on a patch?

Open albfan opened this issue 7 years ago • 5 comments

Given the diff output

commit 5234efaf57b4fac96da75eca554da021 (HEAD, origin/master)
Author: albfan <[email protected]>
Date:   Thu Apr 19 11:43:36 2018 +0000

    My commit

diff --git a/file b/file
index ff249e2..30c8d10 100644
--- a/file
+++ b/file
@@ -4,7 +4,7 @@
        aasdfa
        wertwer
        wetrgsd
-       hello
+       bye
        tryuryt
        rtyurty
        rtyurtuy
diff --git a/foo b/foo
index 1adb588..cd374ea 100644
--- a/foo
+++ b/foo
...
@@ -9,7 +9,7 @@

did you came out with any format to add inline comments?

albfan avatar Apr 19 '18 12:04 albfan

Unfortunately not, when I was actively working on this project Gerrit did not provide an API for inline comments... =(

shanesmith avatar Apr 19 '18 20:04 shanesmith

Does it now? Something like this? https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#fix-replacement-info

If you know the endpoint for it now I can work on it

albfan avatar Apr 20 '18 06:04 albfan

That does look promising. =)

There's an issue however in that this tool was written before Gerrit had a REST API (at least the version we had installed at my work), so instead it uses the older "SSH API" documented here: https://review.openstack.org/Documentation/cmd-index.html

If you can find a way to do it in the end you're more than welcome to submit a PR. =)

shanesmith avatar Apr 23 '18 14:04 shanesmith

Nice. I did similar things in past for old bugzilla CLI, to use its REST API.

Looking at https://www.gerritcodereview.com/releases/README.md I will use gerrit 2.15 to test:

  • (package) https://aur.archlinux.org/packages/gerrit/
  • (docker) https://github.com/GerritCodeReview/docker-gerrit

If you know any avaliable gerrit deploy to play with, let me know. I only know eclipse gerrit, but don't think it is avaliable for tests.

So my plan is to parse a modified diff, like so:

commit 5234efaf57b4fac96da75eca554da021 (HEAD, origin/master)
Author: albfan <[email protected]>
Date:   Thu Apr 19 11:43:36 2018 +0000

    My commit

diff --git a/file b/file
index ff249e2..30c8d10 100644
--- a/file
+++ b/file
@@ -4,7 +4,7 @@
        aasdfa
        wertwer
        wetrgsd
v This is a comment for this hello line
-       hello
+       bye
^ This is a comment for this bye line change
        tryuryt
        rtyurty
        rtyurtuy
diff --git a/foo b/foo
index 1adb588..cd374ea 100644
--- a/foo
+++ b/foo
...
@@ -9,7 +9,7 @@

So ^ means upper line and v means bottom line (line the comment refers too)

albfan avatar Apr 23 '18 14:04 albfan

seems janestreet has been doing this for at least two years https://github.com/janestreet/iron/issues/5

albfan avatar May 30 '18 14:05 albfan