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

Replies to outdated code comments should also be outdated #13217

Conversation

zeripath
Copy link
Contributor

This happened because the comment took the latest commit as its base instead of the
commit_sha of the first comment that it was replying to.

There was also no way of creating an already outdated comment - and a
reply to a review on an outdated line should be outdated.

Signed-off-by: Andrew Thornton art27@cantab.net

…s page

This happened because the comment took the latest commitID as its base instead of the
reviewID that it was replying to.

There was also no way of creating an already outdated comment - and a
reply to a review on an outdated line should be outdated.

Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath
Copy link
Contributor Author

I think we can backport this unless there have been other new migrations since the 1.13 branch.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 20, 2020
Signed-off-by: Andrew Thornton <art27@cantab.net>
@zeripath zeripath force-pushed the comments-on-review-should-have-the-same-sha branch from ca9469e to abc626d Compare October 20, 2020 16:54
@codecov-io
Copy link

Codecov Report

Merging #13217 into master will increase coverage by 0.00%.
The diff coverage is 36.27%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #13217   +/-   ##
=======================================
  Coverage   41.96%   41.96%           
=======================================
  Files         683      684    +1     
  Lines       75279    75360   +81     
=======================================
+ Hits        31589    31628   +39     
- Misses      38524    38563   +39     
- Partials     5166     5169    +3     
Impacted Files Coverage Δ
models/migrations/migrations.go 2.44% <ø> (ø)
models/migrations/v156.go 0.00% <0.00%> (ø)
services/pull/review.go 50.72% <65.30%> (+2.54%) ⬆️
models/issue_comment.go 52.87% <100.00%> (+0.66%) ⬆️
services/pull/pull.go 40.78% <0.00%> (-0.50%) ⬇️
routers/repo/view.go 38.11% <0.00%> (+0.64%) ⬆️
modules/queue/workerpool.go 62.04% <0.00%> (+2.04%) ⬆️
models/unit.go 49.31% <0.00%> (+2.73%) ⬆️
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b50448b...8cba82e. Read the comment docs.

@6543
Copy link
Member

6543 commented Oct 22, 2020

@zeripath pleace resolve :)

@zeripath
Copy link
Contributor Author

I think we should still backport just without the migration perhaps adding to doctor instead...

@zeripath
Copy link
Contributor Author

zeripath commented Oct 22, 2020

BTW @6543 could you take a look at the WIP of mine that refactored doctor? #12264 (don't worry about the conflict at present - I want to see if the idea makes sense before I fix that.)

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 30, 2020
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 4, 2020
@techknowlogick techknowlogick merged commit 3cab3be into go-gitea:master Nov 4, 2020
6543 pushed a commit to 6543-forks/gitea that referenced this pull request Nov 5, 2020
…3217)

* When replying to an outdated comment it should not appear on the files page

This happened because the comment took the latest commitID as its base instead of the
reviewID that it was replying to.

There was also no way of creating an already outdated comment - and a
reply to a review on an outdated line should be outdated.

Signed-off-by: Andrew Thornton <art27@cantab.net>

* fix test

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
@6543
Copy link
Member

6543 commented Nov 5, 2020

Backport: #13433

@6543 6543 added the backport/done All backports for this PR have been created label Nov 5, 2020
@zeripath zeripath deleted the comments-on-review-should-have-the-same-sha branch November 5, 2020 18:19
techknowlogick added a commit that referenced this pull request Nov 5, 2020
…13433)

* When replying to an outdated comment it should not appear on the files page

This happened because the comment took the latest commitID as its base instead of the
reviewID that it was replying to.

There was also no way of creating an already outdated comment - and a
reply to a review on an outdated line should be outdated.

Signed-off-by: Andrew Thornton <art27@cantab.net>

* fix test

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
@@ -976,6 +980,12 @@ func (opts *FindCommentsOptions) toConds() builder.Cond {
if opts.Type != CommentTypeUnknown {
cond = cond.And(builder.Eq{"comment.type": opts.Type})
}
if opts.Line > 0 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there database index on this columns? If not, this will be slow when the database is big.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You only need one index per a query. ReviewID has an index.

AND comment.tree_path = first.tree_path AND comment.line = first.line
WHERE comment.type = 21
AND comment.id != first.id
AND comment.commit_sha != first.commit_sha`).Limit(batchSize, start).Find(&comments); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. SQL and Limit cannot be used both. This may result in horrible memory usage if the sites have many comments.

}

for _, comment := range comments {
if _, err := sess.Table("comment").Cols("commit_sha", "patch", "invalidated").Update(comment); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ID(comment.ID)., oh. God, this will update all the comments

@6543
Copy link
Member

6543 commented Nov 6, 2020

@lunny should we revert #13433 too ?!?

@CirnoT
Copy link
Contributor

CirnoT commented Nov 6, 2020

No, only migration is broken.

@lunny
Copy link
Member

lunny commented Nov 6, 2020

@6543 As @CirnoT said.

@6543
Copy link
Member

6543 commented Nov 6, 2020

this could be why I had issues with #13436 ... too

@silverwind
Copy link
Member

silverwind commented Nov 6, 2020

So a migration was reverted which made existing installs unable to start because it won't downgrade the database. Makes me wonder why we don't have a test that tries to start the server which would have failed in this case :)

@go-gitea go-gitea locked and limited conversation to collaborators Dec 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants