| 25 | } |
| 26 | |
| 27 | func Clone(ctx context.Context, path, remote, checkoutBranch string, singleBranch, shallow bool) error { |
| 28 | args := []string{"clone", remote, path} |
| 29 | if singleBranch { |
| 30 | args = append(args, "--single-branch") |
| 31 | } |
| 32 | if shallow { |
| 33 | args = append(args, "--depth", "1") |
| 34 | } |
| 35 | if checkoutBranch != "" { |
| 36 | args = append(args, "--branch", checkoutBranch) |
| 37 | } |
| 38 | |
| 39 | _, err := Run(ctx, "", args...) |
| 40 | return err |
| 41 | } |
| 42 | |
| 43 | // Checkout checks out a branch using the git command. |
| 44 | // If create is true, it creates the branch (using -B) at the given startPoint. |