From: Sergey Matveev Date: Fri, 17 Jul 2015 12:55:07 +0000 (+0300) Subject: Add line, not the range if single line is commented only X-Git-Tag: 0.1~4 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=09336aa48a8c15f93ce68ef4585d526ba06f9feb;p=gerrvim.git Add line, not the range if single line is commented only --- diff --git a/gerrvim2json.pl b/gerrvim2json.pl index 0cf9c86..bd52c42 100755 --- a/gerrvim2json.pl +++ b/gerrvim2json.pl @@ -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 (<>) {