Spaces:
Sleeping
Sleeping
| from pathlib import Path | |
| from uuid import uuid4 | |
| from git import Repo | |
| class GithubService: | |
| def clone( | |
| self, | |
| url: str, | |
| destination_root: Path, | |
| ): | |
| repo_name = url.rstrip("/").split("/")[-1] | |
| repository_id = uuid4().hex[:8] | |
| folder_name = f"{repo_name}_{repository_id}" | |
| destination = destination_root / folder_name | |
| Repo.clone_from( | |
| url, | |
| destination, | |
| ) | |
| return { | |
| "repository_id": repository_id, | |
| "repo_path": destination, | |
| } | |
| def get_repo( | |
| self, | |
| repo_path, | |
| ): | |
| return Repo(repo_path) |