INNER CODE UNIT · Python

analyze_github_repo

mrwadams/stride-gpt · apps/web/main.py:526

def analyze_github_repo(repo_url):
    # Extract owner and repo name from URL. Normalise the path first so a
    # trailing slash or a ".git" suffix (e.g. ".../repo/" or ".../repo.git")
    # doesn't get baked into the repo name and turn into a spurious 404.
    parsed_url = urlparse(repo_url)
    path = parsed_url.path.rstrip("/")
    if path.endswith(".git"):
        path = path[: -len(".git")]
    parts = [p for p in path.split("/") if p]
    if len(parts) < 2:
        raise ValueError(
            f"'{repo_url}' doesn't look like a GitHub repository URL. "
            "Expected the form https://github.com/owner/repo."
        )
    owner = parts[-2]
    repo_name = parts[-1]

    # Only send the GitHub token to github.com or a host the operator explicitly

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…