Documentation
¶
Overview ¶
Package reporef parses a git repository reference in any common form (https, http, ssh, git, scp style) into host, owner, repo, provider and a canonical clone URL. It is the one parser every repo URL input goes through.
Index ¶
Constants ¶
const ( SchemeHTTPS = "https" SchemeHTTP = "http" SchemeSSH = "ssh" SchemeGit = "git" SchemeSCP = "scp" )
Scheme values for Ref.Scheme. SchemeSCP is the git@host:owner/repo form.
Variables ¶
var ErrUnsupported = errors.New("reporef: not a remote git repository URL")
ErrUnsupported is returned for input that is not a remote repository URL.
Functions ¶
Types ¶
type Provider ¶
type Provider string
Provider is a best guess at the git host software, from the host name only.
type Ref ¶
type Ref struct {
// Scheme is the transport the input used, one of the Scheme constants.
Scheme string
// Host is the lowercase host name without a port.
Host string
// Port is kept only for http and https; an ssh port means nothing over https.
Port string
// Owner is every path segment before the repo, so GitLab subgroups stay intact.
Owner string
// Repo is the last path segment without a ".git" suffix.
Repo string
Provider Provider
// HadCredentials is true when a password or token was stripped from the input.
HadCredentials bool
}
Ref is a parsed repository reference. It never holds credentials.
func ParseWithHost ¶
ParseWithHost is Parse that also accepts "owner/repo" (on defaultHost) and "host.tld/owner/repo" shorthand, the forms import sources store.
func (Ref) CloneURL ¶
CloneURL is the canonical credential-free clone URL: https, or http when the input was plain http.
func (Ref) Identity ¶
Identity is the lowercase path, so every form of one repository compares equal.