Skip to content

Commit 985e378

Browse files
Loïc Dacharyearl-warren
authored andcommitted
[API] fix deleting an issue when the git repo does not exist
Fixes: https://codeberg.org/forgejo/forgejo/issues/629 (cherry picked from commit 5f06dcae267230fc9b22ac171ba7253b47fe0bbf) (cherry picked from commit 1d8ae34e57e46b84a885b4f072d949344c5977c4) (cherry picked from commit 398580975c2c07a14dcf9954fce71f8a4cf28a88) (cherry picked from commit d007bf4)
1 parent 3ad2e63 commit 985e378

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

services/issue/issue.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package issue
55

66
import (
7+
"context"
78
"fmt"
89

910
activities_model "code.gitea.io/gitea/models/activities"
@@ -132,11 +133,17 @@ func UpdateAssignees(issue *issues_model.Issue, oneAssignee string, multipleAssi
132133

133134
// DeleteIssue deletes an issue
134135
func DeleteIssue(doer *user_model.User, gitRepo *git.Repository, issue *issues_model.Issue) error {
136+
var ctx context.Context
137+
if gitRepo == nil {
138+
ctx = db.DefaultContext
139+
} else {
140+
ctx = gitRepo.Ctx
141+
}
135142
// load issue before deleting it
136-
if err := issue.LoadAttributes(gitRepo.Ctx); err != nil {
143+
if err := issue.LoadAttributes(ctx); err != nil {
137144
return err
138145
}
139-
if err := issue.LoadPullRequest(gitRepo.Ctx); err != nil {
146+
if err := issue.LoadPullRequest(ctx); err != nil {
140147
return err
141148
}
142149

@@ -152,7 +159,7 @@ func DeleteIssue(doer *user_model.User, gitRepo *git.Repository, issue *issues_m
152159
}
153160
}
154161

155-
notification.NotifyDeleteIssue(gitRepo.Ctx, doer, issue)
162+
notification.NotifyDeleteIssue(ctx, doer, issue)
156163

157164
return nil
158165
}

0 commit comments

Comments
 (0)