|
27 | 27 | import click |
28 | 28 |
|
29 | 29 | from gitprof import command_utils |
| 30 | +from gitprof import os_utils |
30 | 31 | from gitprof import ssh |
31 | 32 | from gitprof import ux |
32 | 33 | from gitprof.cli import root |
33 | 34 | from gitprof.files import Config, Profile |
34 | 35 | from gitprof.vcs import services |
35 | 36 |
|
36 | 37 |
|
| 38 | +def _create_clone_command(ssh_command, repo, dest) -> str: |
| 39 | + if os_utils.is_windows(): |
| 40 | + return ( |
| 41 | + f"powershell -c " |
| 42 | + + f'"git -c core.sshCommand="""{ssh_command}""" clone {repo}" "{dest}"' |
| 43 | + ) |
| 44 | + |
| 45 | + return f'git -c core.sshCommand="{ssh_command}" clone "{repo}" "{dest}"' |
| 46 | + |
| 47 | + |
37 | 48 | def do_clone( |
38 | 49 | ssh_command: str, repo: str, profile: Profile, dest: str, add_to_known_hosts=False |
39 | 50 | ): |
40 | 51 | if add_to_known_hosts: |
41 | 52 | ssh_command = f"{ssh_command} -o StrictHostKeyChecking=no" |
42 | 53 |
|
43 | | - cmd = ( |
44 | | - f"powershell -c " |
45 | | - f'"git -c core.sshCommand="""{ssh_command}""" clone {repo}" "{dest}"' |
46 | | - ) |
| 54 | + cmd = _create_clone_command(ssh_command, repo, dest) |
47 | 55 |
|
48 | 56 | pipes = subprocess.Popen( |
49 | | - cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE |
| 57 | + cmd, |
| 58 | + stdout=subprocess.PIPE, |
| 59 | + stderr=subprocess.PIPE, |
| 60 | + shell=True, |
50 | 61 | ) |
51 | 62 | stdout, stderr = pipes.communicate() |
52 | 63 |
|
@@ -128,7 +139,9 @@ def advice(): |
128 | 139 | @click.argument("repo") |
129 | 140 | @click.option("-p", "--profile", help="Which profile to clone the repo with") |
130 | 141 | def clone(repo: str, profile: str): |
131 | | - profile = command_utils.create_profile_interactive(profile) |
| 142 | + profile = command_utils.choose_profile_interactive( |
| 143 | + profile, title="Choose a profile to clone with" |
| 144 | + ) |
132 | 145 |
|
133 | 146 | click.echo(f"Cloning '{repo}' with profile: {profile}") |
134 | 147 | profile: Profile = Config().get_profile(name=profile) |
|
0 commit comments