Skip to content

Commit

Permalink
ensure git operations occur in the working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
ccheney authored and p-i- committed Apr 16, 2023
1 parent 1513be4 commit 15059c2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions autogpt/commands/git_operations.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Git operations for autogpt"""
import git
from autogpt.config import Config
from autogpt.workspace import path_in_workspace

CFG = Config()

Expand All @@ -16,8 +17,9 @@ def clone_repository(repo_url: str, clone_path: str) -> str:
str: The result of the clone operation"""
split_url = repo_url.split("//")
auth_repo_url = f"//{CFG.github_username}:{CFG.github_api_key}@".join(split_url)
safe_clone_path = path_in_workspace(clone_path)
try:
git.Repo.clone_from(auth_repo_url, clone_path)
return f"""Cloned {repo_url} to {clone_path}"""
git.Repo.clone_from(auth_repo_url, safe_clone_path)
return f"""Cloned {repo_url} to {safe_clone_path}"""
except Exception as e:
return f"Error: {str(e)}"

0 comments on commit 15059c2

Please sign in to comment.