Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code comments are not invalidated if the line they reference is removed #10686

Closed
1 of 3 tasks
CirnoT opened this issue Mar 9, 2020 · 7 comments · Fixed by #11882
Closed
1 of 3 tasks

Code comments are not invalidated if the line they reference is removed #10686

CirnoT opened this issue Mar 9, 2020 · 7 comments · Fixed by #11882
Labels
Milestone

Comments

@CirnoT
Copy link
Contributor

CirnoT commented Mar 9, 2020

Description

The code comment is not invalidated (marked as outdated) if line it is referencing is removed by future commit. Example can be seen on https://try.gitea.io/CirnoT/checkInvalidation/pulls/1/commits. The comment was made against lines that were removed in a25e77b1d3 however it is not marked as outdated and attempting to comment on it will raise HTTP 500:

[E] CreateCodeComment: LineBlame ... exit status 128 - fatal: file ... has only ... lines
@lakostin
Copy link

lakostin commented Apr 9, 2020

Have the same issue. If i commented line number 100 in file, and in next commit file was reduced to 90 lines, after which someone tries to reply to this comment he gets 500 error.

@CirnoT
Copy link
Contributor Author

CirnoT commented Apr 9, 2020

The error is partially expected, you shouldn't be able to reply on outdated code comments. The underlying issue is the fact that comment is not being marked as outdated.

@guillep2k
Copy link
Member

Personally I'd like to reply to outdated comments, like in GitHub.

@lakostin
Copy link

The error is partially expected, you shouldn't be able to reply on outdated code comments. The underlying issue is the fact that comment is not being marked as outdated.

500 error could not be expected.
One more time: I have 20 lines file, i comment last line, then i delete first 10 lines and get and error trying to reply on the comment to this last line. That shouldn't be an error.

@CirnoT
Copy link
Contributor Author

CirnoT commented Apr 29, 2020

#5455 @zeripath - repro is attached here

@melmus
Copy link

melmus commented May 18, 2020

Sometimes when I add comment in pull request, I have 500 error.

@twostarsmco
Copy link

I just encountered this exact issue. Trying to reply on the comment to 67th line of the file, which has been reduced to 66 lines on the latest commit, I get:

2020/06/05 09:21:37 .../repo/pull_review.go:50:CreateCodeComment() [E] CreateCodeComment: LineBlame[refs/pull/4/head, /data/git/repositories/username/reponame.git, ProjectName/Class1.cs, 67]: exit status 128 - fatal: file ProjectName/Class1.cs has only 66 lines

2020/06/05 09:21:37 ...s/context/context.go:139:HTML() [D] Template: status/500
2020/06/05 09:21:37 .../repo/pull_review.go:50:CreateCodeComment() [E] CreateCodeComment: LineBlame[refs/pull/4/head, /data/git/repositories/username/reponame.git, ProjectName/Class1.cs, 67]: exit status 128 - fatal: file ProjectName/Class1.cs has only 66 lines

zeripath added a commit to zeripath/gitea that referenced this issue Jun 14, 2020
lafriks pushed a commit that referenced this issue Jun 14, 2020
* Invalidate comments when file is shortened

Fix #10686

Signed-off-by: Andrew Thornton <[email protected]>

* handle 1 line

Signed-off-by: Andrew Thornton <[email protected]>
@lafriks lafriks added this to the 1.12.0 milestone Jun 14, 2020
zeripath added a commit to zeripath/gitea that referenced this issue Jun 14, 2020
techknowlogick pushed a commit that referenced this issue Jun 15, 2020
ydelafollye pushed a commit to ydelafollye/gitea that referenced this issue Jul 31, 2020
* Invalidate comments when file is shortened

Fix go-gitea#10686

Signed-off-by: Andrew Thornton <[email protected]>

* handle 1 line

Signed-off-by: Andrew Thornton <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants