Documentation
¶
Index ¶
- Constants
- func EndpointExists(ep Endpoint) (ok bool, err error)
- func EndpointFromRemote(cfg *config.RemoteConfig) (ep *transport.Endpoint, url string, err error)
- func EndpointIsSCP(s string) bool
- func EndpointToDir(base string, ep *transport.Endpoint) string
- func EndpointToSCP(ep *transport.Endpoint) (string, error)
- func EndpointToSlug(ep *transport.Endpoint) string
- func MergeSlug(ep *transport.Endpoint, s string) *transport.Endpoint
- func ParseEndpointOrSlug(s string) (ep *transport.Endpoint, isEndpoint bool, err error)
- func ReplaceSlug(ep *transport.Endpoint, s string) *transport.Endpoint
- type Config
- type Endpoint
- type EndpointTemplate
Constants ¶
const ( // DefaultBranchName is used when cloning an empty repository for the // initial setup. DefaultBranchName = "main" )
Variables ¶
This section is empty.
Functions ¶
func EndpointExists ¶
EndpointExists returns true if url is a Git repository.
func EndpointFromRemote ¶
EndpointFromRemote returns the endpoint used to fetch from r.
func EndpointIsSCP ¶
EndpointIsSCP returns true if s is an SSH URL given in "SCP" style, that is git@github.com:jmalloc/grit.git, as opposed to ssh://git@github.com/jmalloc/grit.git.
func EndpointToDir ¶
EndpointToDir returns the absolute path for a clone of a repository.
func EndpointToSCP ¶
EndpointToSCP converts a normalized ssh:// endpoint URL to an SCP-style URL.
func EndpointToSlug ¶
EndpointToSlug returns the "slug" from ep.
func MergeSlug ¶
MergeSlug returns a copy of ep with the slug changed to s. If s has less path atoms then the existing slug it is merged with the existing slug such that the original number of path atoms are retained.
func ParseEndpointOrSlug ¶
ParseEndpointOrSlug returns an endpoint if s contains a valid endpoint URL. If s is a "slug", isEndpoint is false.
Types ¶
type Config ¶
type Config struct {
Clone struct {
Root string `toml:"root"`
Sources map[string]EndpointTemplate `toml:"sources"`
DefaultBranch string `toml:"default-branch"`
} `toml:"clone"`
Index struct {
Paths []string `toml:"paths"`
Store string `toml:"store"`
} `toml:"index"`
}
Config holds Grit configuration.
func LoadConfig ¶
LoadConfig loads the Grit configuration from a file.
type Endpoint ¶
type Endpoint struct {
// The actual URL used to clone the repository.
// This string will match the URL template from the configuration as closely
// as possible.
Actual string
// The substituted and normalized endpoint template. SCP-style Git URLs
// are converted to ssh:// URLs.
Normalized *transport.Endpoint
}
Endpoint represents a Git clone endpoint, resolved from an EndpointTemplate.
type EndpointTemplate ¶
type EndpointTemplate string
EndpointTemplate is template for a Git repository URL.
func (EndpointTemplate) IsMatch ¶
func (t EndpointTemplate) IsMatch(e *transport.Endpoint) bool
IsMatch returns true if may have been derived from the endpoint template.
func (EndpointTemplate) Resolve ¶
func (t EndpointTemplate) Resolve(slug string) (ep Endpoint, err error)
Resolve returns a URL from the template.
func (EndpointTemplate) Validate ¶
func (t EndpointTemplate) Validate() error
Validate returns an error if the template is invalid.