还原被删除的auto-gpt

This commit is contained in:
w_xiaolizu
2023-05-29 12:34:12 +08:00
parent 2b28f29681
commit 5e201222bb
77 changed files with 7456 additions and 0 deletions

View File

@ -0,0 +1,33 @@
"""Git operations for autogpt"""
from git.repo import Repo
from autogpt.commands.command import command
from autogpt.config import Config
CFG = Config()
@command(
"clone_repository",
"Clone Repository",
'"repository_url": "<repository_url>", "clone_path": "<clone_path>"',
CFG.github_username and CFG.github_api_key,
"Configure github_username and github_api_key.",
)
def clone_repository(repository_url: str, clone_path: str) -> str:
"""Clone a GitHub repository locally.
Args:
repository_url (str): The URL of the repository to clone.
clone_path (str): The path to clone the repository to.
Returns:
str: The result of the clone operation.
"""
split_url = repository_url.split("//")
auth_repo_url = f"//{CFG.github_username}:{CFG.github_api_key}@".join(split_url)
try:
Repo.clone_from(auth_repo_url, clone_path)
return f"""Cloned {repository_url} to {clone_path}"""
except Exception as e:
return f"Error: {str(e)}"