From 72c757b7a44dc5d19d821f7c2fa36bb082e4f2e3 Mon Sep 17 00:00:00 2001 From: Sandro Jäckel Date: Mon, 17 Apr 2023 13:28:47 +0200 Subject: Save rtree with go 1.20 --- internal/rtree/remote.go | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'internal/rtree/remote.go') diff --git a/internal/rtree/remote.go b/internal/rtree/remote.go index 8435979..2973b8c 100644 --- a/internal/rtree/remote.go +++ b/internal/rtree/remote.go @@ -25,18 +25,18 @@ import ( "strings" ) -//RemoteURL is the URL of a remote of a Git repository. +// RemoteURL is the URL of a remote of a Git repository. type RemoteURL string -//ParseRemoteURL parses the given remote URL by substituting aliases defined in -//the system-wide and user-global Git config. For example, with +// ParseRemoteURL parses the given remote URL by substituting aliases defined in +// the system-wide and user-global Git config. For example, with // -// $ cat /etc/gitconfig -// [url "git://github.com/"] -// insteadOf = gh: +// $ cat /etc/gitconfig +// [url "git://github.com/"] +// insteadOf = gh: // -//and the input "gh:foo/bar", the result has a canonical URL of -//"git://github.com/foo/bar". +// and the input "gh:foo/bar", the result has a canonical URL of +// "git://github.com/foo/bar". func ParseRemoteURL(input string) RemoteURL { var best *RemoteAlias for _, current := range RemoteAliases { @@ -52,15 +52,15 @@ func ParseRemoteURL(input string) RemoteURL { return RemoteURL(best.Replacement + strings.TrimPrefix(input, best.Alias)) } -//CanonicalURL returns the URL where the remote will be fetched from. +// CanonicalURL returns the URL where the remote will be fetched from. func (u RemoteURL) CanonicalURL() string { return string(u) } -//CompactURL returns the most compact representation of this remote URL, -//obtained by substituting the longest matching alias defined in the -//system-wide or user-global Git config. This function is mostly the reverse of -//ParseRemoteURL(). +// CompactURL returns the most compact representation of this remote URL, +// obtained by substituting the longest matching alias defined in the +// system-wide or user-global Git config. This function is mostly the reverse of +// ParseRemoteURL(). func (u RemoteURL) CompactURL() string { var best *RemoteAlias for _, current := range RemoteAliases { @@ -76,16 +76,15 @@ func (u RemoteURL) CompactURL() string { return best.Alias + strings.TrimPrefix(string(u), best.Replacement) } -//This regex recognizes the scp-like syntax for git remotes -//(i.e. "[user@]example.org:path/to/repo") as specified by the "GIT URLS" -//section of man:git-clone(1). +// This regex recognizes the scp-like syntax for git remotes +// (i.e. "[user@]example.org:path/to/repo") as specified by the "GIT URLS" +// section of man:git-clone(1). var scpSyntaxRx = regexp.MustCompile(`^(?:[^/@:]+@)?([^/:]+\.[^/:]+):(.+)$`) -//CheckoutPath derives the checkout path for a remote URL. -// -// RemoteURL("https://example.org/foo/bar") -> "example.org/foo/bar" -// RemoteURL("git@example.org:foo/bar.git") -> "example.org/foo/bar" +// CheckoutPath derives the checkout path for a remote URL. // +// RemoteURL("https://example.org/foo/bar") -> "example.org/foo/bar" +// RemoteURL("git@example.org:foo/bar.git") -> "example.org/foo/bar" func (u RemoteURL) CheckoutPath() (string, error) { stripped := strings.TrimSuffix(u.CanonicalURL(), ".git") @@ -102,13 +101,13 @@ func (u RemoteURL) CheckoutPath() (string, error) { return filepath.Join(parsed.Hostname(), parsed.Path), nil } -//MarshalYAML implements the yaml.Marshaler interface. +// MarshalYAML implements the yaml.Marshaler interface. func (u RemoteURL) MarshalYAML() (interface{}, error) { //store URLs in the index in the compact format return u.CompactURL(), nil } -//UnmarshalYAML implements the yaml.Unmarshaler interface. +// UnmarshalYAML implements the yaml.Unmarshaler interface. func (u *RemoteURL) UnmarshalYAML(unmarshal func(interface{}) error) error { var s string err := unmarshal(&s) -- cgit v1.3.1