Module continuous_delivery_scripts.utils.github_helpers
GitHub remote authentication and public Pages URL helpers.
Functions
def authenticated_github_url(remote: str, token: str) ‑> str-
Expand source code
def authenticated_github_url(remote: str, token: str) -> str: """Use GitHub's x-access-token HTTPS credential layout for a repository. Reference: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#githubs-token-formats """ repository = _github_repository_path(remote) if not repository: raise ValueError("Not a GitHub repository remote") suffix = ".git" if remote.rstrip("/").endswith(".git") else "" return f"https://x-access-token:{token}@github.com/{repository}{suffix}"Use GitHub's x-access-token HTTPS credential layout for a repository.
def github_blob_url(remote: str, branch: str, path: str) ‑> str | None-
Expand source code
def github_blob_url(remote: str, branch: str, path: str) -> str | None: """Build a GitHub blob URL for a repository-relative file path.""" repository = _github_repository_path(remote) if not repository: return None cleaned = path.replace("\\", "/").strip("/") if not cleaned: return None encoded_path = "/".join(quote(part, safe="") for part in cleaned.split("/")) return f"https://github.com/{repository}/blob/{quote(branch, safe='')}/{encoded_path}"Build a GitHub blob URL for a repository-relative file path.
def github_pages_candidate(remote: str) ‑> str | None-
Expand source code
def github_pages_candidate(remote: str) -> str | None: """Derive the conventional GitHub Pages address from a GitHub remote.""" repository = _github_repository_path(remote) if not repository: return None owner, name = repository.split("/") return ( f"https://{owner}.github.io/" if name.lower() == f"{owner.lower()}.github.io" else f"https://{owner}.github.io/{name}/" )Derive the conventional GitHub Pages address from a GitHub remote.
def github_pages_url(remote: str) ‑> str | None-
Expand source code
def github_pages_url(remote: str) -> str | None: """Find a verified public Pages site, including a redirected custom domain.""" candidate = github_pages_candidate(remote) return _verified_pages_url(candidate) if candidate else NoneFind a verified public Pages site, including a redirected custom domain.