Skip to content

Commit

Permalink
Fix clone_repository to conform to URL validation (Significant-Grav…
Browse files Browse the repository at this point in the history
…itas#3150)

Co-authored-by: Reinier van der Leer <[email protected]>
  • Loading branch information
SBNovaScript and Pwuts authored Apr 29, 2023
1 parent b8478a9 commit 9c6494a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions autogpt/commands/git_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@
@command(
"clone_repository",
"Clone Repository",
'"repository_url": "<repository_url>", "clone_path": "<clone_path>"',
'"url": "<repository_url>", "clone_path": "<clone_path>"',
CFG.github_username and CFG.github_api_key,
"Configure github_username and github_api_key.",
)
@validate_url
def clone_repository(repository_url: str, clone_path: str) -> str:
def clone_repository(url: str, clone_path: str) -> str:
"""Clone a GitHub repository locally.
Args:
repository_url (str): The URL of the repository to clone.
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("//")
split_url = 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}"""
Repo.clone_from(url=auth_repo_url, to_path=clone_path)
return f"""Cloned {url} to {clone_path}"""
except Exception as e:
return f"Error: {str(e)}"

0 comments on commit 9c6494a

Please sign in to comment.