-
Notifications
You must be signed in to change notification settings - Fork 49
Description
Feature Description
With the imply_local option for DiffView it is now possible to modify the "new" version of the files under review. A user can (by mistake or on purpose) modify a buffer and then attempt to create a comment around the modified lines that will throw this error: gitlab.nvim: Could not create discussion: POST https://.................merge_requests/8/discussions: 400 {message: 400 Bad request - Note {:line_code=>["can't be blank", "must be a valid line code"]}.
I think creating comments on files modified locally does not make sense, so there could be a mechanism that prevents this or at least warns the user that they are trying something odd. gitlab.nvim already checks that there are uncommited changes, but this only happens when starting the review. To successfully prevent the described error to happen, changes to the file on disk and buffer modification could be checked before creating a comment. Alternatively, nomodifiable could be set on the buffer in the "new" version.
Steps to reproduce the comment failure
- Create a
file.txtwith the following old content:
abc
def
ghi
In a feature branch, modify the file like this (this modification is not the point yet, but it's necessary for the file to be part of the MR):
abc
def
ghi
jkl
- In the feature branch, start the review (with
gitlab.review) - In the new version delete the first line ("abc")
- In the old or new version, try to create a comment on line "def" (in the old version it is line 2, in the new version it is now line 1). In both cases the creation fails.