diff options
author | 6543 <6543@obermui.de> | 2022-03-29 21:13:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-30 03:13:41 +0800 |
commit | 3e88af898a7b8e2697f7e4c3867c34b802d0b660 (patch) | |
tree | e8304867b9fd8d78ef0a3da7221d84fb29592c21 /models/repo.go | |
parent | 889a8c268ca6a54ff5be19e61b29b10feb4a12e8 (diff) | |
download | gitea-3e88af898a7b8e2697f7e4c3867c34b802d0b660.tar.gz gitea-3e88af898a7b8e2697f7e4c3867c34b802d0b660.zip |
Make git.OpenRepository accept Context (#19260)
* OpenRepositoryCtx -> OpenRepository
* OpenRepository -> openRepositoryWithDefaultContext, only for internal usage
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/models/repo.go b/models/repo.go index 70539e849b..628a102ee2 100644 --- a/models/repo.go +++ b/models/repo.go @@ -247,8 +247,8 @@ func CanUserForkRepo(user *user_model.User, repo *repo_model.Repository) (bool, } // FindUserOrgForks returns the forked repositories for one user from a repository -func FindUserOrgForks(repoID, userID int64) ([]*repo_model.Repository, error) { - var cond builder.Cond = builder.And( +func FindUserOrgForks(ctx context.Context, repoID, userID int64) ([]*repo_model.Repository, error) { + cond := builder.And( builder.Eq{"fork_id": repoID}, builder.In("owner_id", builder.Select("org_id"). @@ -258,23 +258,23 @@ func FindUserOrgForks(repoID, userID int64) ([]*repo_model.Repository, error) { ) var repos []*repo_model.Repository - return repos, db.GetEngine(db.DefaultContext).Table("repository").Where(cond).Find(&repos) + return repos, db.GetEngine(ctx).Table("repository").Where(cond).Find(&repos) } // GetForksByUserAndOrgs return forked repos of the user and owned orgs -func GetForksByUserAndOrgs(user *user_model.User, repo *repo_model.Repository) ([]*repo_model.Repository, error) { +func GetForksByUserAndOrgs(ctx context.Context, user *user_model.User, repo *repo_model.Repository) ([]*repo_model.Repository, error) { var repoList []*repo_model.Repository if user == nil { return repoList, nil } - forkedRepo, err := repo_model.GetUserFork(repo.ID, user.ID) + forkedRepo, err := repo_model.GetUserFork(ctx, repo.ID, user.ID) if err != nil { return repoList, err } if forkedRepo != nil { repoList = append(repoList, forkedRepo) } - orgForks, err := FindUserOrgForks(repo.ID, user.ID) + orgForks, err := FindUserOrgForks(ctx, repo.ID, user.ID) if err != nil { return nil, err } |