Review comment on line range

A comment on a review is currently uniquely identified by:

  • The SHA of the commit
  • The path of the file relative to this SHA
  • The line number relative to the file

The diff hunk that is also found is redundant and could be re-constructed from the SHA and its parent. The rest is meta information about the comment (author, creation date, update date, reactions).

This can only represent a comment that applies on a single line. Not to a range of lines. The number of lines should be added for that purpose. If it cannot be represented in a forge, it can be ignored. Some information is lost but the comment itself still can be inserted where it has meaning. For instance Forgejo only knows to represent review comments on a single line but GitHub review comments can be related to a range with the line and start_line data fields.

modified   reviewcomment.json
@@ -25,6 +25,10 @@
 	    "description": "The line number of the comment relative to the tree_path.",
 	    "type": "number"
 	},
+	"lines_count": {
+	    "description": "The range of lines that are commented on. If absent it defaults to one and is a single line comment. If specified it must be a positive number. If line is N and lines_count is C, the range of lines commented on is ]N-C,N]. In other words, the range starts lines_count before line, which is the last of the range",
+	    "type": "number"
+	},
 	"commit_id": {
 	    "description": "The SHA of the tree_path commented on.",
 	    "type": "string"

I could not find how review comments are worked on with the GitLab API but I will look closer unless someone knows already.

GitLab knows to comment on multiple lines.