From fe64f2d8a3dee95a5cf7c051bfa8fb27af6c90c8 Mon Sep 17 00:00:00 2001 From: brb Date: Wed, 5 Jul 2023 21:24:49 +0200 Subject: [PATCH] added automatic deletion of preexistent repo dir --- utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/utils.py b/utils.py index 10250c0..aa13286 100644 --- a/utils.py +++ b/utils.py @@ -1,13 +1,16 @@ from pydantic import AnyHttpUrl from pathlib import Path from git import Repo +import shutil def clone_repository(repo_url: AnyHttpUrl) -> Path: # 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) + if dst_dir.exists(): + shutil.rmtree(dst_dir) + dst_dir.mkdir() # git clone repo Repo.clone_from(url=repo_url, to_path=dst_dir) return dst_dir \ No newline at end of file