From ca9a83666eb321bf228c6d849256f13faf001124 Mon Sep 17 00:00:00 2001 From: Aseem Saxena Date: Thu, 17 Apr 2025 21:18:03 -0700 Subject: [PATCH 1/3] fixed --- codeflash/code_utils/git_utils.py | 6 ++++-- tests/test_git_utils.py | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/codeflash/code_utils/git_utils.py b/codeflash/code_utils/git_utils.py index dd82af81d..19dc231d4 100644 --- a/codeflash/code_utils/git_utils.py +++ b/codeflash/code_utils/git_utils.py @@ -82,9 +82,11 @@ def get_git_remotes(repo: Repo) -> list[str]: def get_repo_owner_and_name(repo: Repo | None = None, git_remote: str | None = "origin") -> tuple[str, str]: 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 split_url = remote_url.split("/") - repo_owner_with_github, repo_name = split_url[-2], split_url[-1] + if split_url[-1] == "": + repo_owner_with_github, repo_name = split_url[-3], split_url[-2] + else: + 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 return repo_owner, repo_name 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" From 833545148e0234a757352d6fcfaec6bbb1390f8f Mon Sep 17 00:00:00 2001 From: Aseem Saxena Date: Fri, 18 Apr 2025 15:00:54 -0700 Subject: [PATCH 2/3] Update git_utils.py --- codeflash/code_utils/git_utils.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/codeflash/code_utils/git_utils.py b/codeflash/code_utils/git_utils.py index 19dc231d4..d2af6c5d3 100644 --- a/codeflash/code_utils/git_utils.py +++ b/codeflash/code_utils/git_utils.py @@ -82,11 +82,9 @@ def get_git_remotes(repo: Repo) -> list[str]: def get_repo_owner_and_name(repo: Repo | None = None, git_remote: str | None = "origin") -> tuple[str, str]: 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 = remote_url.rstrip("/") split_url = remote_url.split("/") - if split_url[-1] == "": - repo_owner_with_github, repo_name = split_url[-3], split_url[-2] - else: - repo_owner_with_github, repo_name = split_url[-2], split_url[-1] + 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 return repo_owner, repo_name From 60dfb95fd42369372214cd8751cf08d72a8e6f1e Mon Sep 17 00:00:00 2001 From: Aseem Saxena Date: Fri, 18 Apr 2025 15:11:54 -0700 Subject: [PATCH 3/3] Update git_utils.py --- codeflash/code_utils/git_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/codeflash/code_utils/git_utils.py b/codeflash/code_utils/git_utils.py index d2af6c5d3..2982b05fa 100644 --- a/codeflash/code_utils/git_utils.py +++ b/codeflash/code_utils/git_utils.py @@ -82,6 +82,7 @@ def get_git_remotes(repo: Repo) -> list[str]: def get_repo_owner_and_name(repo: Repo | None = None, git_remote: str | None = "origin") -> tuple[str, str]: 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]