From 1d1bc3797b15b89673abf5a5aa86f1db91f36341 Mon Sep 17 00:00:00 2001 From: Tasha Upchurch Date: Fri, 7 Jul 2023 02:21:15 -0400 Subject: [PATCH] aider: Renamed the function to "validate_git_repo_url" and added logic to check if the git URL is valid. # Context: USER: the function that will be called should verify that the url is a valid git repo, rename the function to something appropriet. --- git.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/git.py b/git.py index eec6c1b..bc5264a 100644 --- a/git.py +++ b/git.py @@ -1,3 +1,5 @@ +import giturlparse + class PublicGitRepo: """replaces the text in the given text string with a given other text at some key positions""" @@ -12,11 +14,15 @@ class PublicGitRepo: CATEGORY = "text" RETURN_TYPES = ("STRING",) - FUNCTION = "prompt_template_handler" + FUNCTION = "validate_git_repo_url" - def prompt_template_handler(self, text: str, replacement, key1, git_url): + def validate_git_repo_url(self, text: str, replacement, key1, git_url): """ - >>> PublicGitRepo().prompt_template_handler("hello world", "universe", "world", "https://github.com/example/repo.git") + >>> PublicGitRepo().validate_git_repo_url("hello world", "universe", "world", "https://github.com/example/repo.git") 'hello universe' """ + parsed_url = giturlparse.parse(git_url) + if not parsed_url.valid: + raise ValueError("Invalid Git repository URL") + return (text.replace(key1, replacement),)