mirror of
https://github.com/go-gitea/gitea
synced 2025-07-12 13:37:20 +00:00
Make git.OpenRepository accept Context (#19260)
* OpenRepositoryCtx -> OpenRepository * OpenRepository -> openRepositoryWithDefaultContext, only for internal usage
This commit is contained in:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user