summaryrefslogtreecommitdiffstats
path: root/modules/repository/init.go
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2022-04-01 10:55:30 +0800
committerGitHub <noreply@github.com>2022-04-01 10:55:30 +0800
commit124b072f0b69650baff086b9688d198f5a6761af (patch)
treefa18f7930053a8408e124875b5dec20e0309332b /modules/repository/init.go
parent3a73645502392110369b5d78fa2c9136e77e4aa2 (diff)
downloadgitea-124b072f0b69650baff086b9688d198f5a6761af.tar.gz
gitea-124b072f0b69650baff086b9688d198f5a6761af.zip
Remove `git.Command.Run` and `git.Command.RunInDir*` (#19280)
Follows #19266, #8553, Close #18553, now there are only three `Run..(&RunOpts{})` functions. * before: `stdout, err := RunInDir(path)` * now: `stdout, _, err := RunStdString(&git.RunOpts{Dir:path})`
Diffstat (limited to 'modules/repository/init.go')
-rw-r--r--modules/repository/init.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/modules/repository/init.go b/modules/repository/init.go
index 3263beadcb..d5a67df5d1 100644
--- a/modules/repository/init.go
+++ b/modules/repository/init.go
@@ -229,9 +229,9 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir,
)
// Clone to temporary path and do the init commit.
- if stdout, err := git.NewCommand(ctx, "clone", repoPath, tmpDir).
+ if stdout, _, err := git.NewCommand(ctx, "clone", repoPath, tmpDir).
SetDescription(fmt.Sprintf("prepareRepoCommit (git clone): %s to %s", repoPath, tmpDir)).
- RunInDirWithEnv("", env); err != nil {
+ RunStdString(&git.RunOpts{Dir: "", Env: env}); err != nil {
log.Error("Failed to clone from %v into %s: stdout: %s\nError: %v", repo, tmpDir, stdout, err)
return fmt.Errorf("git clone: %v", err)
}
@@ -306,9 +306,9 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi
committerName := sig.Name
committerEmail := sig.Email
- if stdout, err := git.NewCommand(ctx, "add", "--all").
+ if stdout, _, err := git.NewCommand(ctx, "add", "--all").
SetDescription(fmt.Sprintf("initRepoCommit (git add): %s", tmpPath)).
- RunInDir(tmpPath); err != nil {
+ RunStdString(&git.RunOpts{Dir: tmpPath}); err != nil {
log.Error("git add --all failed: Stdout: %s\nError: %v", stdout, err)
return fmt.Errorf("git add --all: %v", err)
}
@@ -343,9 +343,9 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi
"GIT_COMMITTER_EMAIL="+committerEmail,
)
- if stdout, err := git.NewCommand(ctx, args...).
+ if stdout, _, err := git.NewCommand(ctx, args...).
SetDescription(fmt.Sprintf("initRepoCommit (git commit): %s", tmpPath)).
- RunInDirWithEnv(tmpPath, env); err != nil {
+ RunStdString(&git.RunOpts{Dir: tmpPath, Env: env}); err != nil {
log.Error("Failed to commit: %v: Stdout: %s\nError: %v", args, stdout, err)
return fmt.Errorf("git commit: %v", err)
}
@@ -354,9 +354,9 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi
defaultBranch = setting.Repository.DefaultBranch
}
- if stdout, err := git.NewCommand(ctx, "push", "origin", "HEAD:"+defaultBranch).
+ if stdout, _, err := git.NewCommand(ctx, "push", "origin", "HEAD:"+defaultBranch).
SetDescription(fmt.Sprintf("initRepoCommit (git push): %s", tmpPath)).
- RunInDirWithEnv(tmpPath, models.InternalPushingEnvironment(u, repo)); err != nil {
+ RunStdString(&git.RunOpts{Dir: tmpPath, Env: models.InternalPushingEnvironment(u, repo)}); err != nil {
log.Error("Failed to push back to HEAD: Stdout: %s\nError: %v", stdout, err)
return fmt.Errorf("git push: %v", err)
}