diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-05-20 22:08:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-20 22:08:52 +0800 |
commit | fd7d83ace60258acf7139c4c787aa8af75b7ba8c (patch) | |
tree | 50038348ec10485f72344f3ac80324e04abc1283 /models/issue_dependency.go | |
parent | d81e31ad7826a81fc7139f329f250594610a274b (diff) | |
download | gitea-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.go | 9 |
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 |