summaryrefslogtreecommitdiffstats
path: root/modules/repository
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2022-02-06 20:01:47 +0100
committerGitHub <noreply@github.com>2022-02-06 20:01:47 +0100
commit3043eb36bfcd7ddf29202b958b91942826a8182b (patch)
treef6bfcb38648f07ff8132558ff826b8b1aac003ec /modules/repository
parent8ae5e6d7fdd577ebf0807bf33a4cdeef35d254d9 (diff)
downloadgitea-3043eb36bfcd7ddf29202b958b91942826a8182b.tar.gz
gitea-3043eb36bfcd7ddf29202b958b91942826a8182b.zip
Delete old git.NewCommand() and use it as git.NewCommandContext() (#18552)
Diffstat (limited to 'modules/repository')
-rw-r--r--modules/repository/create.go2
-rw-r--r--modules/repository/generate.go4
-rw-r--r--modules/repository/init.go8
-rw-r--r--modules/repository/push.go2
-rw-r--r--modules/repository/repo.go4
5 files changed, 10 insertions, 10 deletions
diff --git a/modules/repository/create.go b/modules/repository/create.go
index 8b98a37173..6409cc55ce 100644
--- a/modules/repository/create.go
+++ b/modules/repository/create.go
@@ -111,7 +111,7 @@ func CreateRepository(doer, u *user_model.User, opts models.CreateRepoOptions) (
return fmt.Errorf("checkDaemonExportOK: %v", err)
}
- if stdout, err := git.NewCommandContext(ctx, "update-server-info").
+ if stdout, err := git.NewCommand(ctx, "update-server-info").
SetDescription(fmt.Sprintf("CreateRepository(git update-server-info): %s", repoPath)).
RunInDir(repoPath); err != nil {
log.Error("CreateRepository(git update-server-info) in %v: Stdout: %s\nError: %v", repo, stdout, err)
diff --git a/modules/repository/generate.go b/modules/repository/generate.go
index 5b5e1064aa..d0b5fa0820 100644
--- a/modules/repository/generate.go
+++ b/modules/repository/generate.go
@@ -177,7 +177,7 @@ func generateRepoCommit(ctx context.Context, repo, templateRepo, generateRepo *r
}
repoPath := repo.RepoPath()
- if stdout, err := git.NewCommandContext(ctx, "remote", "add", "origin", repoPath).
+ if stdout, err := git.NewCommand(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)
@@ -281,7 +281,7 @@ func GenerateRepository(ctx context.Context, doer, owner *user_model.User, templ
return generateRepo, fmt.Errorf("checkDaemonExportOK: %v", err)
}
- if stdout, err := git.NewCommandContext(ctx, "update-server-info").
+ if stdout, err := git.NewCommand(ctx, "update-server-info").
SetDescription(fmt.Sprintf("GenerateRepository(git update-server-info): %s", repoPath)).
RunInDir(repoPath); err != nil {
log.Error("GenerateRepository(git update-server-info) in %v: Stdout: %s\nError: %v", generateRepo, stdout, err)
diff --git a/modules/repository/init.go b/modules/repository/init.go
index d6911161de..66d464ef13 100644
--- a/modules/repository/init.go
+++ b/modules/repository/init.go
@@ -40,7 +40,7 @@ func prepareRepoCommit(ctx context.Context, repo *repo_model.Repository, tmpDir,
)
// Clone to temporary path and do the init commit.
- if stdout, err := git.NewCommandContext(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 {
log.Error("Failed to clone from %v into %s: stdout: %s\nError: %v", repo, tmpDir, stdout, err)
@@ -117,7 +117,7 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi
committerName := sig.Name
committerEmail := sig.Email
- if stdout, err := git.NewCommandContext(ctx, "add", "--all").
+ if stdout, err := git.NewCommand(ctx, "add", "--all").
SetDescription(fmt.Sprintf("initRepoCommit (git add): %s", tmpPath)).
RunInDir(tmpPath); err != nil {
log.Error("git add --all failed: Stdout: %s\nError: %v", stdout, err)
@@ -154,7 +154,7 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi
"GIT_COMMITTER_EMAIL="+committerEmail,
)
- if stdout, err := git.NewCommandContext(ctx, args...).
+ if stdout, err := git.NewCommand(ctx, args...).
SetDescription(fmt.Sprintf("initRepoCommit (git commit): %s", tmpPath)).
RunInDirWithEnv(tmpPath, env); err != nil {
log.Error("Failed to commit: %v: Stdout: %s\nError: %v", args, stdout, err)
@@ -165,7 +165,7 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi
defaultBranch = setting.Repository.DefaultBranch
}
- if stdout, err := git.NewCommandContext(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 {
log.Error("Failed to push back to HEAD: Stdout: %s\nError: %v", stdout, err)
diff --git a/modules/repository/push.go b/modules/repository/push.go
index 728e61c839..aa94a3e242 100644
--- a/modules/repository/push.go
+++ b/modules/repository/push.go
@@ -104,7 +104,7 @@ func IsForcePush(ctx context.Context, opts *PushUpdateOptions) (bool, error) {
return false, nil
}
- output, err := git.NewCommandContext(ctx, "rev-list", "--max-count=1", opts.OldCommitID, "^"+opts.NewCommitID).
+ output, err := git.NewCommand(ctx, "rev-list", "--max-count=1", opts.OldCommitID, "^"+opts.NewCommitID).
RunInDir(repo_model.RepoPath(opts.RepoUserName, opts.RepoName))
if err != nil {
return false, err
diff --git a/modules/repository/repo.go b/modules/repository/repo.go
index 22bdf77093..ff022f0aed 100644
--- a/modules/repository/repo.go
+++ b/modules/repository/repo.go
@@ -109,7 +109,7 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
return repo, fmt.Errorf("checkDaemonExportOK: %v", err)
}
- if stdout, err := git.NewCommandContext(ctx, "update-server-info").
+ if stdout, err := git.NewCommand(ctx, "update-server-info").
SetDescription(fmt.Sprintf("MigrateRepositoryGitData(git update-server-info): %s", repoPath)).
RunInDir(repoPath); err != nil {
log.Error("MigrateRepositoryGitData(git update-server-info) in %v: Stdout: %s\nError: %v", repo, stdout, err)
@@ -228,7 +228,7 @@ func CleanUpMigrateInfo(ctx context.Context, repo *repo_model.Repository) (*repo
}
}
- _, err := git.NewCommandContext(ctx, "remote", "rm", "origin").RunInDir(repoPath)
+ _, err := git.NewCommand(ctx, "remote", "rm", "origin").RunInDir(repoPath)
if err != nil && !strings.HasPrefix(err.Error(), "exit status 128 - fatal: No such remote ") {
return repo, fmt.Errorf("CleanUpMigrateInfo: %v", err)
}