Skip to content

Commit e6e8b54

Browse files
Merge branch 'main' into context-import-bug
2 parents 0d77ea4 + 52abe7b commit e6e8b54

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

codeflash/code_utils/git_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def get_repo_owner_and_name(repo: Repo | None = None, git_remote: str | None = "
8383
remote_url = get_remote_url(repo, git_remote) # call only once
8484
remote_url = remote_url.removesuffix(".git") if remote_url.endswith(".git") else remote_url
8585
# remote_url = get_remote_url(repo, git_remote).removesuffix(".git") if remote_url.endswith(".git") else remote_url
86+
remote_url = remote_url.rstrip("/")
8687
split_url = remote_url.split("/")
8788
repo_owner_with_github, repo_name = split_url[-2], split_url[-1]
8889
repo_owner = repo_owner_with_github.split(":")[1] if ":" in repo_owner_with_github else repo_owner_with_github

tests/test_git_utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ def test_test_get_repo_owner_and_name(self, mock_get_remote_url):
3333
assert owner == "owner"
3434
assert repo_name == "repo"
3535

36+
# Test with another GitHub SSH URL
37+
mock_get_remote_url.return_value = "[email protected]:codeflash-ai/posthog/"
38+
owner, repo_name = get_repo_owner_and_name()
39+
assert owner == "codeflash-ai"
40+
assert repo_name == "posthog"
41+
3642
@patch("codeflash.code_utils.git_utils.git.Repo")
3743
def test_check_running_in_git_repo_in_git_repo(self, mock_repo):
3844
mock_repo.return_value.git_dir = "/path/to/repo/.git"

0 commit comments

Comments
 (0)