diff --git a/models/issues/issue_update.go b/models/issues/issue_update.go index 21458e458c..849bc8125e 100644 --- a/models/issues/issue_update.go +++ b/models/issues/issue_update.go @@ -139,7 +139,20 @@ func ReopenIssue(ctx context.Context, issue *Issue, doer *user_model.User) (*Com return nil, err } - return changeIssueStatus(ctx, issue, doer, false, false) + ctx, committer, err := db.TxContext(ctx) + if err != nil { + return nil, err + } + defer committer.Close() + + comment, err := changeIssueStatus(ctx, issue, doer, false, false) + if err != nil { + return nil, err + } + if err := committer.Commit(); err != nil { + return nil, err + } + return comment, nil } // ChangeIssueTitle changes the title of this issue, as the given user. diff --git a/services/issue/status.go b/services/issue/status.go index a7f3ce8f7b..ecbf87d533 100644 --- a/services/issue/status.go +++ b/services/issue/status.go @@ -6,6 +6,7 @@ package issue import ( "context" + "code.gitea.io/gitea/models/db" issues_model "code.gitea.io/gitea/models/issues" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/log" @@ -14,20 +15,31 @@ import ( // CloseIssue close and issue. func CloseIssue(ctx context.Context, issue *issues_model.Issue, doer *user_model.User, commitID string) error { - comment, err := issues_model.CloseIssue(ctx, issue, doer) + dbCtx, committer, err := db.TxContext(ctx) + if err != nil { + return err + } + defer committer.Close() + + comment, err := issues_model.CloseIssue(dbCtx, issue, doer) if err != nil { if issues_model.IsErrDependenciesLeft(err) { - if err := issues_model.FinishIssueStopwatchIfPossible(ctx, doer, issue); err != nil { + if err := issues_model.FinishIssueStopwatchIfPossible(dbCtx, doer, issue); err != nil { log.Error("Unable to stop stopwatch for issue[%d]#%d: %v", issue.ID, issue.Index, err) } } return err } - if err := issues_model.FinishIssueStopwatchIfPossible(ctx, doer, issue); err != nil { + if err := issues_model.FinishIssueStopwatchIfPossible(dbCtx, doer, issue); err != nil { return err } + if err := committer.Commit(); err != nil { + return err + } + committer.Close() + notify_service.IssueChangeStatus(ctx, doer, commitID, issue, comment, true) return nil