Skip to content

Commit

Permalink
Handle GitHub URLs starting with "org-".
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfmanstout committed Jan 19, 2025
1 parent d13389b commit aca4a79
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/repo_guide/cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
import shutil
import textwrap
import threading
Expand Down Expand Up @@ -77,8 +78,8 @@ def __init__(
)
if origin:
self.repo_url = (
origin.url.replace(".git", "")
.replace("git@", "https://")
re.sub(r"^[^@:/]+@", "https://", origin.url)
.replace(".git", "")
.replace(".com:", ".com/")
)
if "github.com" in self.repo_url:
Expand Down
26 changes: 26 additions & 0 deletions tests/test_repo_guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,32 @@ def test_repo_url_with_subdirectory(test_repo: Path, tmp_path: Path) -> None:
)


def test_ssh_org_repo_url(test_repo: Path, tmp_path: Path) -> None:
"""Test SSH-style repo URL parsing."""
repo = git.Repo(test_repo)
# Change origin URL to SSH format
repo.delete_remote(repo.remotes.origin)
repo.create_remote(
"origin", "[email protected]:openai/openai-realtime-solar-system.git"
)

generator = DocGenerator(
input_dir=test_repo,
output_dir=tmp_path / "output",
model_name="",
count_tokens=False,
ignore_patterns=[],
)

assert (
generator.repo_url == "https://github.com/openai/openai-realtime-solar-system"
)
assert (
generator.repo_url_file_prefix
== "https://github.com/openai/openai-realtime-solar-system/blob/main/"
)


@pytest.fixture
def mock_model(monkeypatch):
"""Mock LLM model that returns truncated input as response."""
Expand Down

0 comments on commit aca4a79

Please sign in to comment.