git 逻辑

This commit is contained in:
2026-06-10 15:30:52 +08:00
parent 41f2a84979
commit 023ab2f30e
17 changed files with 221 additions and 64 deletions
+4 -2
View File
@@ -5,7 +5,9 @@ import (
"fmt"
)
// Clone 把 remoteURL 上的 branch 浅克隆到 dst。dst 不能预先存在。
// 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()
@@ -14,7 +16,7 @@ func (r *DefaultRunner) Clone(ctx context.Context, dst, remoteURL, branch string
return fmt.Errorf("credential env: %w", err)
}
defer cleanup()
args := []string{"clone", "--branch", branch, "--single-branch", remoteURL, dst}
args := []string{"clone", "--branch", branch, remoteURL, dst}
_, _, err = r.exec(ctx, "", env, args...)
return err
}