Download app/services/git_handler.py from Dharanidhar1709/Repository-Analysis-Assistant: direct link, hf CLI and curl.
- Browser
- Download file 610 Bytes
-
https://huggingface.co/spaces/Dharanidhar1709/Repository-Analysis-Assistant/resolve/main/app/services/git_handler.py
- Command line
-
hf download hf://spaces/Dharanidhar1709/Repository-Analysis-Assistant/app/services/git_handler.py
-
curl -L -o git_handler.py https://huggingface.co/spaces/Dharanidhar1709/Repository-Analysis-Assistant/resolve/main/app/services/git_handler.py
610 Bytes
| import subprocess | |
| import tempfile | |
| import os | |
| def clone_repo(github_url: str) -> str: | |
| """Clones a GitHub repo to a temp directory, returns the path.""" | |
| temp_dir = tempfile.mkdtemp(prefix="repo_") | |
| try: | |
| subprocess.run( | |
| ["git", "clone", "--depth=1", github_url, temp_dir], | |
| check=True, | |
| capture_output=True, | |
| timeout=60 | |
| ) | |
| except subprocess.CalledProcessError as e: | |
| raise ValueError(f"Git clone failed: {e.stderr.decode()}") | |
| except subprocess.TimeoutExpired: | |
| raise ValueError("Git clone timed out") | |
| return temp_dir |