mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-25 06:25:31 +00:00
[API] fix deleting an issue when the git repo does not exist
Fixes: https://codeberg.org/forgejo/forgejo/issues/629 (cherry picked from commit5f06dcae26
) (cherry picked from commit1d8ae34e57
) (cherry picked from commit398580975c
)
This commit is contained in:
parent
35c580ba03
commit
d007bf4c07
|
@ -4,6 +4,7 @@
|
||||||
package issue
|
package issue
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
activities_model "code.gitea.io/gitea/models/activities"
|
activities_model "code.gitea.io/gitea/models/activities"
|
||||||
|
@ -132,11 +133,17 @@ func UpdateAssignees(issue *issues_model.Issue, oneAssignee string, multipleAssi
|
||||||
|
|
||||||
// DeleteIssue deletes an issue
|
// DeleteIssue deletes an issue
|
||||||
func DeleteIssue(doer *user_model.User, gitRepo *git.Repository, issue *issues_model.Issue) error {
|
func DeleteIssue(doer *user_model.User, gitRepo *git.Repository, issue *issues_model.Issue) error {
|
||||||
|
var ctx context.Context
|
||||||
|
if gitRepo == nil {
|
||||||
|
ctx = db.DefaultContext
|
||||||
|
} else {
|
||||||
|
ctx = gitRepo.Ctx
|
||||||
|
}
|
||||||
// load issue before deleting it
|
// load issue before deleting it
|
||||||
if err := issue.LoadAttributes(gitRepo.Ctx); err != nil {
|
if err := issue.LoadAttributes(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := issue.LoadPullRequest(gitRepo.Ctx); err != nil {
|
if err := issue.LoadPullRequest(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +159,7 @@ func DeleteIssue(doer *user_model.User, gitRepo *git.Repository, issue *issues_m
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
notification.NotifyDeleteIssue(gitRepo.Ctx, doer, issue)
|
notification.NotifyDeleteIssue(ctx, doer, issue)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue