mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-22 08:24:26 +01:00
ensure git operations occur in the working directory
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
"""Git operations for autogpt"""
|
"""Git operations for autogpt"""
|
||||||
import git
|
import git
|
||||||
from autogpt.config import Config
|
from autogpt.config import Config
|
||||||
|
from autogpt.workspace import path_in_workspace
|
||||||
|
|
||||||
CFG = Config()
|
CFG = Config()
|
||||||
|
|
||||||
@@ -16,8 +17,9 @@ def clone_repository(repo_url: str, clone_path: str) -> str:
|
|||||||
str: The result of the clone operation"""
|
str: The result of the clone operation"""
|
||||||
split_url = repo_url.split("//")
|
split_url = repo_url.split("//")
|
||||||
auth_repo_url = f"//{CFG.github_username}:{CFG.github_api_key}@".join(split_url)
|
auth_repo_url = f"//{CFG.github_username}:{CFG.github_api_key}@".join(split_url)
|
||||||
|
safe_clone_path = path_in_workspace(clone_path)
|
||||||
try:
|
try:
|
||||||
git.Repo.clone_from(auth_repo_url, clone_path)
|
git.Repo.clone_from(auth_repo_url, safe_clone_path)
|
||||||
return f"""Cloned {repo_url} to {clone_path}"""
|
return f"""Cloned {repo_url} to {safe_clone_path}"""
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return f"Error: {str(e)}"
|
return f"Error: {str(e)}"
|
||||||
|
|||||||
Reference in New Issue
Block a user