shanesmith / gerrit-cli

Gerrit in your command lines.
MIT License
46 stars 19 forks source link

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

Open albfan opened 6 years ago

albfan commented 6 years ago

Given the diff output

commit 5234efaf57b4fac96da75eca554da021 (HEAD, origin/master)
Author: albfan <albfan@gnome.org>
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?

shanesmith commented 6 years ago

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

albfan commented 6 years ago

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

shanesmith commented 6 years ago

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. =)

albfan commented 6 years ago

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:

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 <albfan@gnome.org>
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 commented 6 years ago

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