mirror of
https://github.com/go-gitea/gitea
synced 2025-07-13 14:07:20 +00:00
Remove context from git struct (#33793)
Argument is moved from struct init in command run, which lets us remove context from struct.
This commit is contained in:
@ -33,13 +33,13 @@ 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").
|
||||
RunStdString(&git.RunOpts{Dir: tmpPath}); err != nil {
|
||||
if stdout, _, err := git.NewCommand("add", "--all").
|
||||
RunStdString(ctx, &git.RunOpts{Dir: tmpPath}); err != nil {
|
||||
log.Error("git add --all failed: Stdout: %s\nError: %v", stdout, err)
|
||||
return fmt.Errorf("git add --all: %w", err)
|
||||
}
|
||||
|
||||
cmd := git.NewCommand(ctx, "commit", "--message=Initial commit").
|
||||
cmd := git.NewCommand("commit", "--message=Initial commit").
|
||||
AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email)
|
||||
|
||||
sign, keyID, signer, _ := asymkey_service.SignInitialCommit(ctx, tmpPath, u)
|
||||
@ -61,7 +61,7 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi
|
||||
)
|
||||
|
||||
if stdout, _, err := cmd.
|
||||
RunStdString(&git.RunOpts{Dir: tmpPath, Env: env}); err != nil {
|
||||
RunStdString(ctx, &git.RunOpts{Dir: tmpPath, Env: env}); err != nil {
|
||||
log.Error("Failed to commit: %v: Stdout: %s\nError: %v", cmd.LogString(), stdout, err)
|
||||
return fmt.Errorf("git commit: %w", err)
|
||||
}
|
||||
@ -70,8 +70,8 @@ func initRepoCommit(ctx context.Context, tmpPath string, repo *repo_model.Reposi
|
||||
defaultBranch = setting.Repository.DefaultBranch
|
||||
}
|
||||
|
||||
if stdout, _, err := git.NewCommand(ctx, "push", "origin").AddDynamicArguments("HEAD:" + defaultBranch).
|
||||
RunStdString(&git.RunOpts{Dir: tmpPath, Env: repo_module.InternalPushingEnvironment(u, repo)}); err != nil {
|
||||
if stdout, _, err := git.NewCommand("push", "origin").AddDynamicArguments("HEAD:"+defaultBranch).
|
||||
RunStdString(ctx, &git.RunOpts{Dir: tmpPath, Env: repo_module.InternalPushingEnvironment(u, repo)}); err != nil {
|
||||
log.Error("Failed to push back to HEAD: Stdout: %s\nError: %v", stdout, err)
|
||||
return fmt.Errorf("git push: %w", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user