1
0
Fork 0
forked from forgejo/forgejo

Use context parameter in services/repository (#23186)

Use context parameter in `services/repository`.

And use `cache.WithCacheContext(ctx)` to generate push action history
feeds.

Fix #23160
This commit is contained in:
Jason Song 2023-03-01 06:17:51 +08:00 committed by GitHub
parent cbbd3726b4
commit 04347eb810
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 102 additions and 100 deletions

View file

@ -40,7 +40,7 @@ func GenerateIssueLabels(ctx context.Context, templateRepo, generateRepo *repo_m
}
// GenerateRepository generates a repository from a template
func GenerateRepository(doer, owner *user_model.User, templateRepo *repo_model.Repository, opts repo_module.GenerateRepoOptions) (_ *repo_model.Repository, err error) {
func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templateRepo *repo_model.Repository, opts repo_module.GenerateRepoOptions) (_ *repo_model.Repository, err error) {
if !doer.IsAdmin && !owner.CanCreateRepo() {
return nil, repo_model.ErrReachLimitOfRepo{
Limit: owner.MaxRepoCreation,
@ -48,7 +48,7 @@ func GenerateRepository(doer, owner *user_model.User, templateRepo *repo_model.R
}
var generateRepo *repo_model.Repository
if err = db.WithTx(db.DefaultContext, func(ctx context.Context) error {
if err = db.WithTx(ctx, func(ctx context.Context) error {
generateRepo, err = repo_module.GenerateRepository(ctx, doer, owner, templateRepo, opts)
if err != nil {
return err
@ -101,7 +101,7 @@ func GenerateRepository(doer, owner *user_model.User, templateRepo *repo_model.R
return nil, err
}
notification.NotifyCreateRepository(db.DefaultContext, doer, owner, generateRepo)
notification.NotifyCreateRepository(ctx, doer, owner, generateRepo)
return generateRepo, nil
}