summaryrefslogtreecommitdiffstats
path: root/modules/repository/generate.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-09-23 16:45:36 +0100
committerGitHub <noreply@github.com>2021-09-23 23:45:36 +0800
commit9302eba971611601c3ebf6024e22a11c63f4e151 (patch)
treea3e5583986161ef62e7affc694098279ecf2217d /modules/repository/generate.go
parentb22be7f594401d7bd81196750456ce52185bd391 (diff)
downloadgitea-9302eba971611601c3ebf6024e22a11c63f4e151.tar.gz
gitea-9302eba971611601c3ebf6024e22a11c63f4e151.zip
DBContext is just a Context (#17100)
* DBContext is just a Context This PR removes some of the specialness from the DBContext and makes it context This allows us to simplify the GetEngine code to wrap around any context in future and means that we can change our loadRepo(e Engine) functions to simply take contexts. Signed-off-by: Andrew Thornton <art27@cantab.net> * fix unit tests Signed-off-by: Andrew Thornton <art27@cantab.net> * another place that needs to set the initial context Signed-off-by: Andrew Thornton <art27@cantab.net> * avoid race Signed-off-by: Andrew Thornton <art27@cantab.net> * change attachment error Signed-off-by: Andrew Thornton <art27@cantab.net>
Diffstat (limited to 'modules/repository/generate.go')
-rw-r--r--modules/repository/generate.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/repository/generate.go b/modules/repository/generate.go
index 8ab518add5..4fcebc06dc 100644
--- a/modules/repository/generate.go
+++ b/modules/repository/generate.go
@@ -5,6 +5,7 @@
package repository
import (
+ "context"
"fmt"
"os"
"path"
@@ -13,7 +14,6 @@ import (
"time"
"code.gitea.io/gitea/models"
- "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/util"
@@ -185,7 +185,7 @@ func generateRepoCommit(repo, templateRepo, generateRepo *models.Repository, tmp
return initRepoCommit(tmpDir, repo, repo.Owner, templateRepo.DefaultBranch)
}
-func generateGitContent(ctx *db.Context, repo, templateRepo, generateRepo *models.Repository) (err error) {
+func generateGitContent(ctx context.Context, repo, templateRepo, generateRepo *models.Repository) (err error) {
tmpDir, err := os.MkdirTemp(os.TempDir(), "gitea-"+repo.Name)
if err != nil {
return fmt.Errorf("Failed to create temp dir for repository %s: %v", repo.RepoPath(), err)
@@ -223,7 +223,7 @@ func generateGitContent(ctx *db.Context, repo, templateRepo, generateRepo *model
}
// GenerateGitContent generates git content from a template repository
-func GenerateGitContent(ctx *db.Context, templateRepo, generateRepo *models.Repository) error {
+func GenerateGitContent(ctx context.Context, templateRepo, generateRepo *models.Repository) error {
if err := generateGitContent(ctx, generateRepo, templateRepo, generateRepo); err != nil {
return err
}
@@ -239,7 +239,7 @@ func GenerateGitContent(ctx *db.Context, templateRepo, generateRepo *models.Repo
}
// GenerateRepository generates a repository from a template
-func GenerateRepository(ctx *db.Context, doer, owner *models.User, templateRepo *models.Repository, opts models.GenerateRepoOptions) (_ *models.Repository, err error) {
+func GenerateRepository(ctx context.Context, doer, owner *models.User, templateRepo *models.Repository, opts models.GenerateRepoOptions) (_ *models.Repository, err error) {
generateRepo := &models.Repository{
OwnerID: owner.ID,
Owner: owner,