Documentation ¶
Overview ¶
Package config collects together all configuration settings NOTE: Subject to change, do not rely on this package from outside git-lfs source
Index ¶
- Constants
- Variables
- func Bool(value string, def bool) bool
- func Int(value string, def int) int
- type Configuration
- func (c *Configuration) BasicTransfersOnly() bool
- func (c *Configuration) Cleanup() error
- func (c *Configuration) CurrentCommitter() (name, email string)
- func (c *Configuration) CurrentRef() *git.Ref
- func (c *Configuration) EachLFSObject(fn func(fs.Object) error) error
- func (c *Configuration) Extensions() map[string]Extension
- func (c *Configuration) FetchExcludePaths() []string
- func (c *Configuration) FetchIncludePaths() []string
- func (c *Configuration) Filesystem() *fs.Filesystem
- func (c *Configuration) FindGitGlobalKey(key string) string
- func (c *Configuration) FindGitLocalKey(key string) string
- func (c *Configuration) FindGitSystemKey(key string) string
- func (c *Configuration) GitConfig() *git.Configuration
- func (c *Configuration) GitEnv() Environment
- func (c *Configuration) HookDir() string
- func (c *Configuration) InRepo() bool
- func (c *Configuration) IsDefaultRemote() bool
- func (c *Configuration) LFSObjectDir() string
- func (c *Configuration) LFSObjectExists(oid string, size int64) bool
- func (c *Configuration) LFSStorageDir() string
- func (c *Configuration) LocalGitDir() string
- func (c *Configuration) LocalGitStorageDir() string
- func (c *Configuration) LocalLogDir() string
- func (c *Configuration) LocalReferenceDirs() []string
- func (c *Configuration) LocalWorkingDir() string
- func (c *Configuration) OSEnv() Environment
- func (c *Configuration) PushRemote() string
- func (c *Configuration) Remote() string
- func (c *Configuration) Remotes() []string
- func (c *Configuration) SetGitGlobalKey(key, val string) (string, error)
- func (c *Configuration) SetGitLocalKey(key, val string) (string, error)
- func (c *Configuration) SetGitSystemKey(key, val string) (string, error)
- func (c *Configuration) SetLockableFilesReadOnly() bool
- func (c *Configuration) SetPushRemote(name string)
- func (c *Configuration) SetRemote(name string)
- func (c *Configuration) SetValidPushRemote(name string) error
- func (c *Configuration) SetValidRemote(name string) error
- func (c *Configuration) SkipDownloadErrors() bool
- func (c *Configuration) SortedExtensions() ([]Extension, error)
- func (c *Configuration) TempDir() string
- func (c *Configuration) TusTransfersAllowed() bool
- func (c *Configuration) UnsetGitGlobalSection(key string) (string, error)
- func (c *Configuration) UnsetGitLocalKey(key string) (string, error)
- func (c *Configuration) UnsetGitLocalSection(key string) (string, error)
- func (c *Configuration) UnsetGitSystemSection(key string) (string, error)
- type Environment
- type Extension
- type Fetcher
- type GitFetcher
- type OsFetcher
- type URLConfig
- type Values
Constants ¶
const (
Version = "2.5.2"
)
Variables ¶
var ( GitCommit string VersionDesc string )
var (
ShowConfigWarnings = false
)
Functions ¶
func Bool ¶
Bool returns the boolean state associated with the given value, or the value "def", if the value is blank.
The "boolean state associated with a given key" is defined as the case-insensitive string comparison with the following:
- true if... "true", "1", "on", "yes", or "t"
- false if... "false", "0", "off", "no", "f", or otherwise.
func Int ¶
Int returns the int value associated with the given value, or the value "def", if the value is blank.
To convert from a the string value attached to a given key, `strconv.Atoi(val)` is called. If `Atoi` returned a non-nil error, then the value "def" will be returned instead.
Otherwise, if the value was converted `string -> int` successfully, then it will be returned wholesale.
Types ¶
type Configuration ¶
type Configuration struct { // Os provides a `*Environment` used to access to the system's // environment through os.Getenv. It is the point of entry for all // system environment configuration. Os Environment // Git provides a `*Environment` used to access to the various levels of // `.gitconfig`'s. It is the point of entry for all Git environment // configuration. Git Environment // contains filtered or unexported fields }
func New ¶
func New() *Configuration
func NewFrom ¶
func NewFrom(v Values) *Configuration
NewFrom returns a new `*config.Configuration` that reads both its Git and Enviornment-level values from the ones provided instead of the actual `.gitconfig` file or `os.Getenv`, respectively.
This method should only be used during testing.
func NewIn ¶
func NewIn(workdir, gitdir string) *Configuration
func (*Configuration) BasicTransfersOnly ¶
func (c *Configuration) BasicTransfersOnly() bool
BasicTransfersOnly returns whether to only allow "basic" HTTP transfers. Default is false, including if the lfs.basictransfersonly is invalid
func (*Configuration) Cleanup ¶
func (c *Configuration) Cleanup() error
func (*Configuration) CurrentCommitter ¶
func (c *Configuration) CurrentCommitter() (name, email string)
CurrentCommitter returns the name/email that would be used to author a commit with this configuration. In particular, the "user.name" and "user.email" configuration values are used
func (*Configuration) CurrentRef ¶
func (c *Configuration) CurrentRef() *git.Ref
func (*Configuration) EachLFSObject ¶
func (c *Configuration) EachLFSObject(fn func(fs.Object) error) error
func (*Configuration) Extensions ¶
func (c *Configuration) Extensions() map[string]Extension
func (*Configuration) FetchExcludePaths ¶
func (c *Configuration) FetchExcludePaths() []string
func (*Configuration) FetchIncludePaths ¶
func (c *Configuration) FetchIncludePaths() []string
func (*Configuration) Filesystem ¶
func (c *Configuration) Filesystem() *fs.Filesystem
func (*Configuration) FindGitGlobalKey ¶
func (c *Configuration) FindGitGlobalKey(key string) string
func (*Configuration) FindGitLocalKey ¶
func (c *Configuration) FindGitLocalKey(key string) string
func (*Configuration) FindGitSystemKey ¶
func (c *Configuration) FindGitSystemKey(key string) string
func (*Configuration) GitConfig ¶
func (c *Configuration) GitConfig() *git.Configuration
func (*Configuration) GitEnv ¶
func (c *Configuration) GitEnv() Environment
func (*Configuration) HookDir ¶
func (c *Configuration) HookDir() string
func (*Configuration) InRepo ¶
func (c *Configuration) InRepo() bool
func (*Configuration) IsDefaultRemote ¶
func (c *Configuration) IsDefaultRemote() bool
func (*Configuration) LFSObjectDir ¶
func (c *Configuration) LFSObjectDir() string
func (*Configuration) LFSObjectExists ¶
func (c *Configuration) LFSObjectExists(oid string, size int64) bool
func (*Configuration) LFSStorageDir ¶
func (c *Configuration) LFSStorageDir() string
func (*Configuration) LocalGitDir ¶
func (c *Configuration) LocalGitDir() string
func (*Configuration) LocalGitStorageDir ¶
func (c *Configuration) LocalGitStorageDir() string
func (*Configuration) LocalLogDir ¶
func (c *Configuration) LocalLogDir() string
func (*Configuration) LocalReferenceDirs ¶
func (c *Configuration) LocalReferenceDirs() []string
func (*Configuration) LocalWorkingDir ¶
func (c *Configuration) LocalWorkingDir() string
func (*Configuration) OSEnv ¶
func (c *Configuration) OSEnv() Environment
func (*Configuration) PushRemote ¶
func (c *Configuration) PushRemote() string
func (*Configuration) Remote ¶
func (c *Configuration) Remote() string
Remote returns the default remote based on: 1. The currently tracked remote branch, if present 2. Any other SINGLE remote defined in .git/config 3. Use "origin" as a fallback. Results are cached after the first hit.
func (*Configuration) Remotes ¶
func (c *Configuration) Remotes() []string
func (*Configuration) SetGitGlobalKey ¶
func (c *Configuration) SetGitGlobalKey(key, val string) (string, error)
func (*Configuration) SetGitLocalKey ¶
func (c *Configuration) SetGitLocalKey(key, val string) (string, error)
func (*Configuration) SetGitSystemKey ¶
func (c *Configuration) SetGitSystemKey(key, val string) (string, error)
func (*Configuration) SetLockableFilesReadOnly ¶
func (c *Configuration) SetLockableFilesReadOnly() bool
func (*Configuration) SetPushRemote ¶
func (c *Configuration) SetPushRemote(name string)
func (*Configuration) SetRemote ¶
func (c *Configuration) SetRemote(name string)
func (*Configuration) SetValidPushRemote ¶
func (c *Configuration) SetValidPushRemote(name string) error
func (*Configuration) SetValidRemote ¶
func (c *Configuration) SetValidRemote(name string) error
func (*Configuration) SkipDownloadErrors ¶
func (c *Configuration) SkipDownloadErrors() bool
func (*Configuration) SortedExtensions ¶
func (c *Configuration) SortedExtensions() ([]Extension, error)
SortedExtensions gets the list of extensions ordered by Priority
func (*Configuration) TempDir ¶
func (c *Configuration) TempDir() string
func (*Configuration) TusTransfersAllowed ¶
func (c *Configuration) TusTransfersAllowed() bool
TusTransfersAllowed returns whether to only use "tus.io" HTTP transfers. Default is false, including if the lfs.tustransfers is invalid
func (*Configuration) UnsetGitGlobalSection ¶
func (c *Configuration) UnsetGitGlobalSection(key string) (string, error)
func (*Configuration) UnsetGitLocalKey ¶
func (c *Configuration) UnsetGitLocalKey(key string) (string, error)
func (*Configuration) UnsetGitLocalSection ¶
func (c *Configuration) UnsetGitLocalSection(key string) (string, error)
func (*Configuration) UnsetGitSystemSection ¶
func (c *Configuration) UnsetGitSystemSection(key string) (string, error)
type Environment ¶
type Environment interface { // Get is shorthand for calling `e.Fetcher.Get(key)`. Get(key string) (val string, ok bool) // Get is shorthand for calling `e.Fetcher.GetAll(key)`. GetAll(key string) (vals []string) // Bool returns the boolean state associated with a given key, or the // value "def", if no value was associated. // // The "boolean state associated with a given key" is defined as the // case-insensitive string comparison with the following: // // 1) true if... // "true", "1", "on", "yes", or "t" // 2) false if... // "false", "0", "off", "no", "f", or otherwise. Bool(key string, def bool) (val bool) // Int returns the int value associated with a given key, or the value // "def", if no value was associated. // // To convert from a the string value attached to a given key, // `strconv.Atoi(val)` is called. If `Atoi` returned a non-nil error, // then the value "def" will be returned instead. // // Otherwise, if the value was converted `string -> int` successfully, // then it will be returned wholesale. Int(key string, def int) (val int) // All returns a copy of all the key/value pairs for the current // environment. All() map[string][]string }
An Environment adds additional behavior to a Fetcher, such a type conversion, and default values.
`Environment`s are the primary way to communicate with various configuration sources, such as the OS environment variables, the `.gitconfig`, and even `map[string]string`s.
func EnvironmentOf ¶
func EnvironmentOf(f Fetcher) Environment
EnvironmentOf creates a new `Environment` initialized with the givne `Fetcher`, "f".
type Extension ¶
An Extension describes how to manipulate files during smudge and clean. Extensions are parsed from the Git config.
type Fetcher ¶
type Fetcher interface { // Get returns the string value associated with a given key and a bool // determining if the key exists. // // If multiple entries match the given key, the first one will be // returned. Get(key string) (val string, ok bool) // GetAll returns the a set of string values associated with a given // key. If no entries matched the given key, an empty slice will be // returned instead. GetAll(key string) (vals []string) // All returns a copy of all the key/value pairs for the current // environment. All() map[string][]string }
Fetcher provides an interface to get typed information out of a configuration "source". These sources could be the OS enviornment, a .gitconfig, or even just a `map`.
func MapFetcher ¶
func UniqMapFetcher ¶
type GitFetcher ¶
type GitFetcher struct {
// contains filtered or unexported fields
}
func (*GitFetcher) All ¶
func (g *GitFetcher) All() map[string][]string
func (*GitFetcher) Get ¶
func (g *GitFetcher) Get(key string) (val string, ok bool)
Get implements the Fetcher interface, and returns the value associated with a given key and true, signaling that the value was present. Otherwise, an empty string and false will be returned, signaling that the value was absent.
Map lookup by key is case-insensitive, as per the .gitconfig specification.
Get is safe to call across multiple goroutines.
func (*GitFetcher) GetAll ¶
func (g *GitFetcher) GetAll(key string) []string
type OsFetcher ¶
type OsFetcher struct {
// contains filtered or unexported fields
}
OsFetcher is an implementation of the Fetcher type for communicating with the system's environment.
It is safe to use across multiple goroutines.
func (*OsFetcher) Get ¶
Get returns the value associated with the given key as stored in the local cache, or in the operating system's environment variables.
If there was a cache-hit, the value will be returned from the cache, skipping a check against os.Getenv. Otherwise, the value will be fetched from the system, stored in the cache, and then returned. If no value was present in the cache or in the system, an empty string will be returned.
Get is safe to call across multiple goroutines.
type URLConfig ¶
type URLConfig struct {
// contains filtered or unexported fields
}
func NewURLConfig ¶
func NewURLConfig(git Environment) *URLConfig
func (*URLConfig) Get ¶
Get retrieves a `http.{url}.{key}` for the given key and urls, following the rules in https://git-scm.com/docs/git-config#git-config-httplturlgt. The value for `http.{key}` is returned as a fallback if no config keys are set for the given urls.
type Values ¶
type Values struct {
// Git and Os are the stand-in maps used to provide values for their
// respective environments.
Git, Os map[string][]string
}
Values is a convenience type used to call the NewFromValues function. It specifies `Git` and `Env` maps to use as mock values, instead of calling out to real `.gitconfig`s and the `os.Getenv` function.