summaryrefslogtreecommitdiffstats
path: root/models/issue_dependency.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-05-20 22:08:52 +0800
committerGitHub <noreply@github.com>2022-05-20 22:08:52 +0800
commitfd7d83ace60258acf7139c4c787aa8af75b7ba8c (patch)
tree50038348ec10485f72344f3ac80324e04abc1283 /models/issue_dependency.go
parentd81e31ad7826a81fc7139f329f250594610a274b (diff)
downloadgitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.tar.gz
gitea-fd7d83ace60258acf7139c4c787aa8af75b7ba8c.zip
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context * remove some unnecessary wrap functions
Diffstat (limited to 'models/issue_dependency.go')
-rw-r--r--models/issue_dependency.go9
1 files changed, 4 insertions, 5 deletions
diff --git a/models/issue_dependency.go b/models/issue_dependency.go
index b292db57e0..af40aa45d3 100644
--- a/models/issue_dependency.go
+++ b/models/issue_dependency.go
@@ -42,10 +42,9 @@ func CreateIssueDependency(user *user_model.User, issue, dep *Issue) error {
return err
}
defer committer.Close()
- sess := db.GetEngine(ctx)
// Check if it aleready exists
- exists, err := issueDepExists(sess, issue.ID, dep.ID)
+ exists, err := issueDepExists(ctx, issue.ID, dep.ID)
if err != nil {
return err
}
@@ -53,7 +52,7 @@ func CreateIssueDependency(user *user_model.User, issue, dep *Issue) error {
return ErrDependencyExists{issue.ID, dep.ID}
}
// And if it would be circular
- circular, err := issueDepExists(sess, dep.ID, issue.ID)
+ circular, err := issueDepExists(ctx, dep.ID, issue.ID)
if err != nil {
return err
}
@@ -114,8 +113,8 @@ func RemoveIssueDependency(user *user_model.User, issue, dep *Issue, depType Dep
}
// Check if the dependency already exists
-func issueDepExists(e db.Engine, issueID, depID int64) (bool, error) {
- return e.Where("(issue_id = ? AND dependency_id = ?)", issueID, depID).Exist(&IssueDependency{})
+func issueDepExists(ctx context.Context, issueID, depID int64) (bool, error) {
+ return db.GetEngine(ctx).Where("(issue_id = ? AND dependency_id = ?)", issueID, depID).Exist(&IssueDependency{})
}
// IssueNoDependenciesLeft checks if issue can be closed