From 15a5c10d33fd3c0b9483316b19712e981bf2391d Mon Sep 17 00:00:00 2001 From: John Olheiser <42128690+jolheiser@users.noreply.github.com> Date: Sat, 30 Nov 2019 00:54:47 -0600 Subject: Variable expansion in repository templates (#9163) * Start expansion Signed-off-by: jolheiser * _template rather than .template Signed-off-by: jolheiser * Use ioutil Signed-off-by: jolheiser * Add descriptions to mapping * Start globbing Signed-off-by: jolheiser * Tune globbing Signed-off-by: jolheiser * Re-arrange imports Signed-off-by: jolheiser * Don't expand git hooks Signed-off-by: jolheiser * Add glob tests for .giteatemplate Signed-off-by: jolheiser * Parse globs separately so they can be tested more easily Signed-off-by: jolheiser * Change template location and add docs Signed-off-by: jolheiser * nit Signed-off-by: jolheiser * Update docs/content/doc/features/gitea-directory.md Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Update docs/content/doc/features/gitea-directory.md Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> * Add upper-lower case match Signed-off-by: jolheiser * Nits Signed-off-by: jolheiser * Update models/repo_generate.go Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> --- models/repo.go | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) (limited to 'models/repo.go') diff --git a/models/repo.go b/models/repo.go index cbe1ccc4f6..0ccf786db3 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1361,54 +1361,6 @@ func prepareRepoCommit(e Engine, repo *Repository, tmpDir, repoPath string, opts return nil } -func generateRepoCommit(e Engine, repo, templateRepo *Repository, tmpDir string) error { - commitTimeStr := time.Now().Format(time.RFC3339) - authorSig := repo.Owner.NewGitSig() - - // Because this may call hooks we should pass in the environment - env := append(os.Environ(), - "GIT_AUTHOR_NAME="+authorSig.Name, - "GIT_AUTHOR_EMAIL="+authorSig.Email, - "GIT_AUTHOR_DATE="+commitTimeStr, - "GIT_COMMITTER_NAME="+authorSig.Name, - "GIT_COMMITTER_EMAIL="+authorSig.Email, - "GIT_COMMITTER_DATE="+commitTimeStr, - ) - - // Clone to temporary path and do the init commit. - templateRepoPath := templateRepo.repoPath(e) - _, stderr, err := process.GetManager().ExecDirEnv( - -1, "", - fmt.Sprintf("generateRepoCommit(git clone): %s", templateRepoPath), - env, - git.GitExecutable, "clone", "--depth", "1", templateRepoPath, tmpDir, - ) - if err != nil { - return fmt.Errorf("git clone: %v - %s", err, stderr) - } - - if err := os.RemoveAll(path.Join(tmpDir, ".git")); err != nil { - return fmt.Errorf("remove git dir: %v", err) - } - - if err := git.InitRepository(tmpDir, false); err != nil { - return err - } - - repoPath := repo.repoPath(e) - _, stderr, err = process.GetManager().ExecDirEnv( - -1, tmpDir, - fmt.Sprintf("generateRepoCommit(git remote add): %s", repoPath), - env, - git.GitExecutable, "remote", "add", "origin", repoPath, - ) - if err != nil { - return fmt.Errorf("git remote add: %v - %s", err, stderr) - } - - return initRepoCommit(tmpDir, repo.Owner) -} - func checkInitRepository(repoPath string) (err error) { // Somehow the directory could exist. if com.IsExist(repoPath) { -- cgit v1.2.3