diff --git a/codeflash/code_utils/git_utils.py b/codeflash/code_utils/git_utils.py index dd82af81d..2982b05fa 100644 --- a/codeflash/code_utils/git_utils.py +++ b/codeflash/code_utils/git_utils.py @@ -83,6 +83,7 @@ def get_repo_owner_and_name(repo: Repo | None = None, git_remote: str | None = " remote_url = get_remote_url(repo, git_remote) # call only once remote_url = remote_url.removesuffix(".git") if remote_url.endswith(".git") else remote_url # remote_url = get_remote_url(repo, git_remote).removesuffix(".git") if remote_url.endswith(".git") else remote_url + remote_url = remote_url.rstrip("/") split_url = remote_url.split("/") repo_owner_with_github, repo_name = split_url[-2], split_url[-1] repo_owner = repo_owner_with_github.split(":")[1] if ":" in repo_owner_with_github else repo_owner_with_github diff --git a/tests/test_git_utils.py b/tests/test_git_utils.py index 94cb9d5ac..f456a0d90 100644 --- a/tests/test_git_utils.py +++ b/tests/test_git_utils.py @@ -33,6 +33,12 @@ def test_test_get_repo_owner_and_name(self, mock_get_remote_url): assert owner == "owner" assert repo_name == "repo" + # Test with another GitHub SSH URL + mock_get_remote_url.return_value = "git@github.com:codeflash-ai/posthog/" + owner, repo_name = get_repo_owner_and_name() + assert owner == "codeflash-ai" + assert repo_name == "posthog" + @patch("codeflash.code_utils.git_utils.git.Repo") def test_check_running_in_git_repo_in_git_repo(self, mock_repo): mock_repo.return_value.git_dir = "/path/to/repo/.git"