From a68307707e07963b62a5ba3b023e076ff385f4cc Mon Sep 17 00:00:00 2001 From: brb Date: Wed, 5 Jul 2023 20:51:45 +0200 Subject: [PATCH] used gitpython to clone repo --- utils.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils.py b/utils.py index 11a6c92..b1eeb52 100644 --- a/utils.py +++ b/utils.py @@ -1,9 +1,14 @@ from pydantic import AnyHttpUrl from pathlib import Path +from git import Repo def clone_repository(repo_url: AnyHttpUrl) -> Path: print(f'cloning into {repo_url}') + # extract repo name repo_name = repo_url.split('/')[-1].replace('.git', '') dst_dir = Path(__file__).parent / repo_name + # prepare repo download dir dst_dir.mkdir(exist_ok=True) + # git clone repo + Repo.clone_from(url=repo_url, to_path=dst_dir) return dst_dir \ No newline at end of file