From 6fe35175a7fcab7179c8f4f45d1e7ad10a1eeecb Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 10 Nov 2024 13:45:31 -0800 Subject: [PATCH] Add transaction for CloseIssue --- models/issues/issue_update.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/models/issues/issue_update.go b/models/issues/issue_update.go index 849bc8125e..6766e7bbc5 100644 --- a/models/issues/issue_update.go +++ b/models/issues/issue_update.go @@ -127,7 +127,20 @@ func CloseIssue(ctx context.Context, issue *Issue, doer *user_model.User) (*Comm return nil, err } - return changeIssueStatus(ctx, issue, doer, true, false) + ctx, committer, err := db.TxContext(ctx) + if err != nil { + return nil, err + } + defer committer.Close() + + comment, err := changeIssueStatus(ctx, issue, doer, true, false) + if err != nil { + return nil, err + } + if err := committer.Commit(); err != nil { + return nil, err + } + return comment, nil } // ChangeIssueStatus changes issue status to open or closed.