You've already forked agentic-coding-workflow
23 lines
700 B
Go
23 lines
700 B
Go
package git
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
)
|
|
|
|
// Clone 把 remoteURL 克隆到 dst(初始 checkout 指定 branch)。dst 不能预先存在。
|
|
// 不加 --single-branch:保留全部远端分支,使后续 fetch --all 与基于其他分支建
|
|
// worktree 可行。
|
|
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, remoteURL, dst}
|
|
_, _, err = r.exec(ctx, "", env, args...)
|
|
return err
|
|
}
|