mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Comments on review should have the same sha (#13448)
* 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> * Fix broken migration Signed-off-by: Andrew Thornton <art27@cantab.net> * fix mssql Signed-off-by: Andrew Thornton <art27@cantab.net> * Create temporary table because ... well MSSQL ... Signed-off-by: Andrew Thornton <art27@cantab.net> * Create temporary table because ... well MSSQL ... Signed-off-by: Andrew Thornton <art27@cantab.net> * Create temporary table because ... well MSSQL ... Signed-off-by: Andrew Thornton <art27@cantab.net> * fix mssql Signed-off-by: Andrew Thornton <art27@cantab.net> * move session within the batch Signed-off-by: Andrew Thornton <art27@cantab.net> * regen the sqlcmd each time round the loop Signed-off-by: Andrew Thornton <art27@cantab.net> * as per @lunny Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
@@ -712,6 +712,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
|
||||
RefAction: opts.RefAction,
|
||||
RefIsPull: opts.RefIsPull,
|
||||
IsForcePush: opts.IsForcePush,
|
||||
Invalidated: opts.Invalidated,
|
||||
}
|
||||
if _, err = e.Insert(comment); err != nil {
|
||||
return nil, err
|
||||
@@ -878,6 +879,7 @@ type CreateCommentOptions struct {
|
||||
RefAction references.XRefAction
|
||||
RefIsPull bool
|
||||
IsForcePush bool
|
||||
Invalidated bool
|
||||
}
|
||||
|
||||
// CreateComment creates comment of issue or commit.
|
||||
@@ -953,6 +955,8 @@ type FindCommentsOptions struct {
|
||||
ReviewID int64
|
||||
Since int64
|
||||
Before int64
|
||||
Line int64
|
||||
TreePath string
|
||||
Type CommentType
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
cond = cond.And(builder.Eq{"comment.line": opts.Line})
|
||||
}
|
||||
if len(opts.TreePath) > 0 {
|
||||
cond = cond.And(builder.Eq{"comment.tree_path": opts.TreePath})
|
||||
}
|
||||
return cond
|
||||
}
|
||||
|
||||
@@ -990,6 +1000,8 @@ func findComments(e Engine, opts FindCommentsOptions) ([]*Comment, error) {
|
||||
sess = opts.setSessionPagination(sess)
|
||||
}
|
||||
|
||||
// WARNING: If you change this order you will need to fix createCodeComment
|
||||
|
||||
return comments, sess.
|
||||
Asc("comment.created_unix").
|
||||
Asc("comment.id").
|
||||
|
Reference in New Issue
Block a user