aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorcaicandong <50507092+CaiCandong@users.noreply.github.com>2023-08-04 21:34:34 +0800
committerGitHub <noreply@github.com>2023-08-04 13:34:34 +0000
commit6151e69d9509c08e25e93743d6b31211371e81d0 (patch)
tree1e115a29a615805d0cc533b5de242dfe5adde80a /models
parent2de0752be7aaab65fe670518d00175be479ea054 (diff)
downloadgitea-6151e69d9509c08e25e93743d6b31211371e81d0.tar.gz
gitea-6151e69d9509c08e25e93743d6b31211371e81d0.zip
Delete `issue_service.CreateComment` (#26298)
I noticed that `issue_service.CreateComment` adds transaction operations on `issues_model.CreateComment`, we can merge the two functions and we can avoid calling each other's methods in the `services` layer. Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'models')
-rw-r--r--models/issues/comment.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/models/issues/comment.go b/models/issues/comment.go
index be020b2e1f..e781931261 100644
--- a/models/issues/comment.go
+++ b/models/issues/comment.go
@@ -777,6 +777,12 @@ func (c *Comment) LoadPushCommits(ctx context.Context) (err error) {
// CreateComment creates comment with context
func CreateComment(ctx context.Context, opts *CreateCommentOptions) (_ *Comment, err error) {
+ ctx, committer, err := db.TxContext(ctx)
+ if err != nil {
+ return nil, err
+ }
+ defer committer.Close()
+
e := db.GetEngine(ctx)
var LabelID int64
if opts.Label != nil {
@@ -832,7 +838,9 @@ func CreateComment(ctx context.Context, opts *CreateCommentOptions) (_ *Comment,
if err = comment.AddCrossReferences(ctx, opts.Doer, false); err != nil {
return nil, err
}
-
+ if err = committer.Commit(); err != nil {
+ return nil, err
+ }
return comment, nil
}