feat(infra/git): clone/fetch/push/commit/status verbs + integration tests

This commit is contained in:
2026-05-01 21:43:56 +08:00
parent f8c7771892
commit faecb05ebd
10 changed files with 280 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
package git
import (
"context"
"fmt"
)
// Clone 把 remoteURL 上的 branch 浅克隆到 dst。dst 不能预先存在。
func (r *DefaultRunner) Clone(ctx context.Context, dst, remoteURL, branch string, cred *Credential) error {
ctx, cancel := withCtx(ctx, r.cfg.CloneTimeout)
defer cancel()
env, cleanup, err := credentialEnv(r.cfg.TmpDir, cred)
if err != nil {
return fmt.Errorf("credential env: %w", err)
}
defer cleanup()
args := []string{"clone", "--branch", branch, "--single-branch", remoteURL, dst}
_, _, err = r.exec(ctx, "", env, args...)
return err
}