-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Improvements to content history #17746
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
Changes from all commits
e574f78
8ab05a0
0dc7e5c
b25731e
547cee9
1899189
4a8e899
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,10 +25,6 @@ func CreateIssueComment(doer *models.User, repo *models.Repository, issue *model | |
if err != nil { | ||
return nil, err | ||
} | ||
err = issues.SaveIssueContentHistory(db.GetEngine(db.DefaultContext), doer.ID, issue.ID, comment.ID, timeutil.TimeStampNow(), comment.Content, true) | ||
lunny marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
mentions, err := issue.FindAndUpdateIssueMentions(db.DefaultContext, doer, comment.Content) | ||
if err != nil { | ||
|
@@ -42,11 +38,26 @@ func CreateIssueComment(doer *models.User, repo *models.Repository, issue *model | |
|
||
// UpdateComment updates information of comment. | ||
func UpdateComment(c *models.Comment, doer *models.User, oldContent string) error { | ||
var needsContentHistory = c.Content != oldContent && | ||
(c.Type == models.CommentTypeComment || c.Type == models.CommentTypeReview || c.Type == models.CommentTypeCode) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have content history for "pending" code comments on non-submitted review? GitHub doesn't do that either. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't thought about it. For a simple idea, if the logic is not complex then we can have it, but if we need to pay much effect to follow the GitHub behavior, well, it depends 😂. Both are fine to me.
wxiaoguang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if needsContentHistory { | ||
hasContentHistory, err := issues.HasIssueContentHistory(db.DefaultContext, c.IssueID, c.ID) | ||
if err != nil { | ||
return err | ||
} | ||
if !hasContentHistory { | ||
if err = issues.SaveIssueContentHistory(db.GetEngine(db.DefaultContext), c.PosterID, c.IssueID, c.ID, | ||
c.CreatedUnix, oldContent, true); err != nil { | ||
return err | ||
} | ||
} | ||
} | ||
|
||
if err := models.UpdateComment(c, doer); err != nil { | ||
return err | ||
} | ||
|
||
if c.Type == models.CommentTypeComment && c.Content != oldContent { | ||
if needsContentHistory { | ||
err := issues.SaveIssueContentHistory(db.GetEngine(db.DefaultContext), doer.ID, c.IssueID, c.ID, timeutil.TimeStampNow(), c.Content, false) | ||
if err != nil { | ||
return err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just return the error but add a special log here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it just follows my first PR, a personal preference for error handling.
Usually I would like to report important errors as early as possible.
Otherwise: