Merge branch 'ssh-mirroring' of github.com:techknowlogick/gitea into techknowlogick-ssh-mirroring

This commit is contained in:
Lunny Xiao
2025-09-25 12:24:11 -07:00
30 changed files with 1654 additions and 28 deletions
+10
View File
@@ -220,6 +220,10 @@ type RunOpts struct {
// In the future, ideally the git module itself should have full control of the stdin, to avoid such problems and make it easier to refactor to a better architecture.
Stdin io.Reader
// SSHAuthSock is the path to an SSH agent socket for authentication
// If provided, SSH_AUTH_SOCK environment variable will be set
SSHAuthSock string
PipelineFunc func(context.Context, context.CancelFunc) error
}
@@ -319,6 +323,11 @@ func (c *Command) run(ctx context.Context, skip int, opts *RunOpts) error {
process.SetSysProcAttribute(cmd)
cmd.Env = append(cmd.Env, CommonGitCmdEnvs()...)
if opts.SSHAuthSock != "" {
cmd.Env = append(cmd.Env, "SSH_AUTH_SOCK="+opts.SSHAuthSock)
}
cmd.Dir = opts.Dir
cmd.Stdout = opts.Stdout
cmd.Stderr = opts.Stderr
@@ -434,6 +443,7 @@ func (c *Command) runStdBytes(ctx context.Context, opts *RunOpts) (stdout, stder
Stdout: stdoutBuf,
Stderr: stderrBuf,
Stdin: opts.Stdin,
SSHAuthSock: opts.SSHAuthSock,
PipelineFunc: opts.PipelineFunc,
}