make a python function that takes in a git url and a file destination which the clone…
- User
make a python function that takes in a git url and a file destination which the clone the given git to the destinatio, if the git is already existing then just pull
Assistant
Here is a Python function that clones or pulls a Git repository based on if it already exists locally:
pythonimport shutil import subprocess def clone_or_pull(git_url, dest_dir): if not os.path.exists(dest_dir): print(f"Cloning {git_url} to {dest_dir}") subprocess.run(["git", "clone", git_url, dest_dir]) else: print(f"Pulling updates from {git_url} to {dest_dir}") os.chdir(dest_dir) subprocess.run(["git", "pull"])
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.