Expand description
Provide lightweight GitHub helpers using the gh CLI.
Provide focused wrappers around gh subcommands plus URL parsing helpers for PR IDs and remote
canonicalization.
§Rationale
This module shells out to the GitHub CLI (‘gh’) instead of using a direct HTTP client (e.g. octocrab) because:
- Reuses the user’s existing authenticated
ghsession (no PAT / device-flow code, fewer secrets to manage). - Keeps this utility crate synchronous and lightweight (avoids adding
tokio+reqwestdependency graph). - Minimizes compile time and binary size in the broader workspace.
- Leverages ‘gh’ stable porcelain for JSON output (
--json/--jq) and future compatibility with GitHub auth flows / SSO. - Current feature surface (latest release tag, PR head branch lookup) is small; process spawn overhead is negligible versus HTTP setup cost.
Trade-offs accepted:
- Less fine-grained control over rate limiting and retries.
- Tight coupling to
ghoutput flags (low churn historically, but still external). - Requires
ghbinary presence in runtime environments.
Modules§
Enums§
- Repo
View Field - Repository fields available for querying via
gh repo view.
Constants§
- GITHUB_
HOST 🔒 - The GitHub host domain.
- GITHUB_
PR_ 🔒ID_ PREFIX - The URL path segment prefix for pull requests.
- GITHUB_
PR_ 🔒ID_ QUERY_ KEY - The query parameter key used for pull request IDs in GitHub Actions URLs.
Functions§
- extract_
pr_ 🔒id_ form_ url - Extracts the pull request numeric ID from a GitHub URL.
- get_
branch_ name_ from_ url - Extracts the branch name from a GitHub pull request
Url. - get_
latest_ release - Retrieves the latest release tag name for the specified GitHub repository.
- get_
repo_ urls - Returns all GitHub remote URLs for the repository rooted at
repo_path. - get_
repo_ view_ field - Return the specified repository field via
gh repo view. - log_
into_ github - Ensures the user is authenticated with the GitHub CLI.
- parse_
github_ 🔒url_ from_ git_ remote_ url - Converts a Git remote URL (SSH or HTTPS) to a canonical GitHub HTTPS URL without the
.gitsuffix.