Documentation
¶
Overview ¶
Package gitremote provides general-purpose git remote URL utilities: parsing, resolving, and redacting remote URLs. It has no dependency on checkpoint, strategy, or settings packages.
Index ¶
- Constants
- func ExtractOwnerFromRemoteURL(rawURL string) string
- func GetRemoteURL(ctx context.Context, remoteName string) (string, error)
- func GetRemoteURLInDir(ctx context.Context, dir, remoteName string) (string, error)
- func RedactURL(rawURL string) string
- func ResolveRemoteRepo(ctx context.Context, remoteName string) (forge, owner, repo string, err error)
- type Info
Constants ¶
const ( ProtocolSSH = "ssh" ProtocolHTTPS = "https" // ProtocolEntire is the scheme of Entire's git remote helper (entire://). // These URLs carry a forge/namespace prefix before owner/repo. ProtocolEntire = "entire" )
Variables ¶
This section is empty.
Functions ¶
func ExtractOwnerFromRemoteURL ¶
ExtractOwnerFromRemoteURL extracts the owner component from a git remote URL. Returns an empty string if the URL cannot be parsed.
func GetRemoteURL ¶
GetRemoteURL returns the URL configured for the named git remote.
func GetRemoteURLInDir ¶ added in v0.6.3
GetRemoteURLInDir returns the URL configured for the named git remote in dir.
func RedactURL ¶
RedactURL removes credentials and query parameters from a URL for safe logging. SCP-style SSH URLs (e.g., git@github.com:org/repo.git) are returned as-is since they contain no embedded credentials.
func ResolveRemoteRepo ¶
func ResolveRemoteRepo(ctx context.Context, remoteName string) (forge, owner, repo string, err error)
ResolveRemoteRepo returns the forge identifier, owner, and repo name for the given git remote. The forge is the short id used by the trails API ("gh", "et", ...); it is derived from the hostname for direct git URLs or from the path prefix on entire:// URLs. It is empty for unrecognized hosts. For example, git@github.com:org/my-repo.git returns ("gh", "org", "my-repo").
Types ¶
type Info ¶
Info holds the parsed components of a git remote URL. Host is the hostname only (never includes a port). Port is empty unless the source URL specified an explicit non-default port. Callers that need the combined "host[:port]" form should use HostPort.
Forge is the short identifier of the upstream forge ("gh", "et", ...) used by the Entire trails API. It is populated from the path prefix on entire:// URLs (entire://host/<forge>/owner/repo) and from a hostname lookup on direct git URLs (github.com → "gh"). It is empty for direct git URLs to unrecognized hosts, and for entire:// URLs without a forge segment.