]> Sergey Matveev's repositories - gerrvim.git/commitdiff
Add line, not the range if single line is commented only
authorSergey Matveev <stargrave@stargrave.org>
Fri, 17 Jul 2015 12:55:07 +0000 (15:55 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 17 Jul 2015 12:55:07 +0000 (15:55 +0300)
gerrvim2json.pl

index 0cf9c869e6410a856ec82533e3242399a200945a..bd52c4201a180a1c83530a286a807a752a12b952 100755 (executable)
@@ -54,10 +54,7 @@ is transformed to JSON like this:
           },
           {
             "message": "Remove that.",
-            "range": {
-              "end_line": "2",
-              "start_line": "1"
-            }
+            "line": 1
           }
         ]
       }
@@ -115,10 +112,13 @@ sub buf2str {
 
 sub comment_done {
     ($comments{$filename} = []) unless defined $comments{$filename};
-    push @{$comments{$filename}}, {
-        range => {start_line => $linebgn, end_line => $lineend},
-        message => buf2str,
+    my %c = ("message" => buf2str);
+    if ($lineend - $linebgn == 1) {
+        $c{"line"} = $linebgn;
+    } else {
+        $c{"range"} = {start_line => $linebgn, end_line => $lineend};
     };
+    push @{$comments{$filename}}, \%c;
 }
 
 while (<>) {