diff options
Diffstat (limited to 'modules/repository/generate.go')
-rw-r--r-- | modules/repository/generate.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/modules/repository/generate.go b/modules/repository/generate.go index 3f83f51bb7..c7ba617919 100644 --- a/modules/repository/generate.go +++ b/modules/repository/generate.go @@ -99,7 +99,7 @@ func checkGiteaTemplate(tmpDir string) (*models.GiteaTemplate, error) { return gt, nil } -func generateRepoCommit(repo, templateRepo, generateRepo *repo_model.Repository, tmpDir string) error { +func generateRepoCommit(ctx context.Context, repo, templateRepo, generateRepo *repo_model.Repository, tmpDir string) error { commitTimeStr := time.Now().Format(time.RFC3339) authorSig := repo.Owner.NewGitSig() @@ -115,7 +115,7 @@ func generateRepoCommit(repo, templateRepo, generateRepo *repo_model.Repository, // Clone to temporary path and do the init commit. templateRepoPath := templateRepo.RepoPath() - if err := git.Clone(templateRepoPath, tmpDir, git.CloneRepoOptions{ + if err := git.Clone(ctx, templateRepoPath, tmpDir, git.CloneRepoOptions{ Depth: 1, Branch: templateRepo.DefaultBranch, }); err != nil { @@ -172,19 +172,19 @@ func generateRepoCommit(repo, templateRepo, generateRepo *repo_model.Repository, } } - if err := git.InitRepository(tmpDir, false); err != nil { + if err := git.InitRepository(ctx, tmpDir, false); err != nil { return err } repoPath := repo.RepoPath() - if stdout, err := git.NewCommand("remote", "add", "origin", repoPath). + if stdout, err := git.NewCommandContext(ctx, "remote", "add", "origin", repoPath). SetDescription(fmt.Sprintf("generateRepoCommit (git remote add): %s to %s", templateRepoPath, tmpDir)). RunInDirWithEnv(tmpDir, env); err != nil { log.Error("Unable to add %v as remote origin to temporary repo to %s: stdout %s\nError: %v", repo, tmpDir, stdout, err) return fmt.Errorf("git remote add: %v", err) } - return initRepoCommit(tmpDir, repo, repo.Owner, templateRepo.DefaultBranch) + return initRepoCommit(ctx, tmpDir, repo, repo.Owner, templateRepo.DefaultBranch) } func generateGitContent(ctx context.Context, repo, templateRepo, generateRepo *repo_model.Repository) (err error) { @@ -199,7 +199,7 @@ func generateGitContent(ctx context.Context, repo, templateRepo, generateRepo *r } }() - if err = generateRepoCommit(repo, templateRepo, generateRepo, tmpDir); err != nil { + if err = generateRepoCommit(ctx, repo, templateRepo, generateRepo, tmpDir); err != nil { return fmt.Errorf("generateRepoCommit: %v", err) } @@ -209,7 +209,7 @@ func generateGitContent(ctx context.Context, repo, templateRepo, generateRepo *r } repo.DefaultBranch = templateRepo.DefaultBranch - gitRepo, err := git.OpenRepository(repo.RepoPath()) + gitRepo, err := git.OpenRepositoryCtx(ctx, repo.RepoPath()) if err != nil { return fmt.Errorf("openRepository: %v", err) } @@ -273,7 +273,7 @@ func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templ } } - if err = checkInitRepository(owner.Name, generateRepo.Name); err != nil { + if err = checkInitRepository(ctx, owner.Name, generateRepo.Name); err != nil { return generateRepo, err } |