Documentation
¶
Overview ¶
Package repourl parses git remote URLs into the host/owner/name identity gitten keys repositories by. It is pure: no git, no filesystem.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckNoCredentials ¶
CheckNoCredentials returns an error naming the URL, redacted, when it embeds a credential. gitten keeps URLs in state and logs, so it never accepts one.
func HasCredentials ¶
HasCredentials reports whether a remote URL embeds a credential: any user info in an http(s) URL, where a token often travels as the user name, or a password in any other URL. The user in git@host:path is not a credential.
func IsHTTP ¶
IsHTTP reports whether u is an http(s) URL, whose auth goes through git's credential helper rather than an SSH key.
func MatchKey ¶
MatchKey reports whether repo key host/owner/name matches pattern: a key, or a glob over keys in which * matches any run of characters, slashes included, ? matches one, and [...] (or [!...]) one in or out of a class. So github.com/acme/* is every repo of acme, subgroups included, ghes.company.com/* every repo on that host, and */api every repo named api. A malformed pattern matches nothing; ValidatePattern reports it.
func Redact ¶
Redact hides credentials in any remote URLs within text: all user info of http(s) URLs, the password of others.
func ValidatePattern ¶
ValidatePattern returns an error when pattern isn't a well-formed glob.
func WithoutCredentials ¶
WithoutCredentials returns raw with any credential HasCredentials finds taken out: the user info of an http(s) URL, the password of another. It is what to keep of a URL read from a repository's config, which a person may have put a token in; git's credential helper supplies it instead.
Types ¶
type Identity ¶
type Identity struct {
Host string // "github.com"
Owner string // "ashtonian"
Name string // "gitten"
FullName string // "ashtonian/gitten"
SSHURL string // canonical "git@github.com:ashtonian/gitten.git"
URL string // the original input URL, verbatim (preserves scheme/port)
}
Identity represents parsed identity from a git remote URL.
func Parse ¶
Parse parses a git remote URL into identity components. It accepts every form git itself does:
- scp-like SSH: git@host:owner/repo.git (or any user@)
- ssh:// URLs: ssh://git@host[:port]/owner/repo.git
- http(s): https://host[:port]/owner/repo.git (userinfo/port stripped)
- git://: git://host/owner/repo.git
- local paths: /path/to/repo[.git], file://…, ~/repos/x.git
Owner may be a multi-segment path (GitLab subgroups). For local remotes, which have no real host/owner, Host is "local", Owner is the parent dir, and Name is the repo dir — enough to form a stable tracking key.