used gitpython to clone repo
This commit is contained in:
@@ -1,9 +1,14 @@
|
|||||||
from pydantic import AnyHttpUrl
|
from pydantic import AnyHttpUrl
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from git import Repo
|
||||||
|
|
||||||
def clone_repository(repo_url: AnyHttpUrl) -> Path:
|
def clone_repository(repo_url: AnyHttpUrl) -> Path:
|
||||||
print(f'cloning into {repo_url}')
|
print(f'cloning into {repo_url}')
|
||||||
|
# extract repo name
|
||||||
repo_name = repo_url.split('/')[-1].replace('.git', '')
|
repo_name = repo_url.split('/')[-1].replace('.git', '')
|
||||||
dst_dir = Path(__file__).parent / repo_name
|
dst_dir = Path(__file__).parent / repo_name
|
||||||
|
# prepare repo download dir
|
||||||
dst_dir.mkdir(exist_ok=True)
|
dst_dir.mkdir(exist_ok=True)
|
||||||
|
# git clone repo
|
||||||
|
Repo.clone_from(url=repo_url, to_path=dst_dir)
|
||||||
return dst_dir
|
return dst_dir
|
||||||
Reference in New Issue
Block a user