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 ResolveGitBasicDirs()
- type Configuration
- func (c *Configuration) BasicTransfersOnly() bool
- func (c *Configuration) CurrentCommitter() (name, email string)
- func (c *Configuration) Extensions() map[string]Extension
- func (c *Configuration) FetchExcludePaths() []string
- func (c *Configuration) FetchIncludePaths() []string
- func (c *Configuration) FetchPruneConfig() FetchPruneConfig
- func (c *Configuration) Remotes() []string
- func (c *Configuration) SetLockableFilesReadOnly() bool
- func (c *Configuration) SkipDownloadErrors() bool
- func (c *Configuration) SortedExtensions() ([]Extension, error)
- func (c *Configuration) TusTransfersAllowed() bool
- func (c *Configuration) Unmarshal(v interface{}) error
- type Environment
- type Extension
- type FetchPruneConfig
- type Fetcher
- type GitConfig
- type GitFetcher
- type OsFetcher
- type URLConfig
- type Values
Constants ¶
const (
Version = "2.2.0"
)
Variables ¶
var ( Config = New() ShowConfigWarnings = false )
var ( LocalWorkingDir string LocalGitDir string // parent of index / config / hooks etc LocalGitStorageDir string // parent of objects/lfs (may be same as LocalGitDir but may not) LocalReferenceDir string // alternative local media dir (relative to clone reference repo) LocalLogDir string )
var ( GitCommit string VersionDesc string )
Functions ¶
func ResolveGitBasicDirs ¶
func ResolveGitBasicDirs()
Determins the LocalWorkingDir, LocalGitDir etc
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 CurrentRemote string // contains filtered or unexported fields }
func New ¶ added in v1.3.1
func New() *Configuration
func NewFrom ¶ added in v1.4.0
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 (*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) 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) 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) FetchPruneConfig ¶
func (c *Configuration) FetchPruneConfig() FetchPruneConfig
func (*Configuration) Remotes ¶
func (c *Configuration) Remotes() []string
func (*Configuration) SetLockableFilesReadOnly ¶
func (c *Configuration) SetLockableFilesReadOnly() bool
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) 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) Unmarshal ¶ added in v1.4.0
func (c *Configuration) Unmarshal(v interface{}) error
Unmarshal unmarshals the *Configuration in context into all of `v`'s fields, according to the following rules:
Values are marshaled according to the given key and environment, as follows:
type T struct { Field string `git:"key"` Other string `os:"key"` }
If an unknown environment is given, an error will be returned. If there is no method supporting conversion into a field's type, an error will be returned. If no value is associated with the given key and environment, the field will // only be modified if there is a config value present matching the given key. If the field is already set to a non-zero value of that field's type, then it will be left alone.
Otherwise, the field will be set to the value of calling the appropriately-typed method on the specified environment.
type Environment ¶ added in v1.4.0
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 ¶ added in v1.4.0
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 FetchPruneConfig ¶
type FetchPruneConfig struct { // The number of days prior to current date for which (local) refs other than HEAD // will be fetched with --recent (default 7, 0 = only fetch HEAD) FetchRecentRefsDays int `git:"lfs.fetchrecentrefsdays"` // Makes the FetchRecentRefsDays option apply to remote refs from fetch source as well (default true) FetchRecentRefsIncludeRemotes bool `git:"lfs.fetchrecentremoterefs"` // number of days prior to latest commit on a ref that we'll fetch previous // LFS changes too (default 0 = only fetch at ref) FetchRecentCommitsDays int `git:"lfs.fetchrecentcommitsdays"` // Whether to always fetch recent even without --recent FetchRecentAlways bool `git:"lfs.fetchrecentalways"` // Number of days added to FetchRecent*; data outside combined window will be // deleted when prune is run. (default 3) PruneOffsetDays int `git:"lfs.pruneoffsetdays"` // Always verify with remote before pruning PruneVerifyRemoteAlways bool `git:"lfs.pruneverifyremotealways"` // Name of remote to check for unpushed and verify checks PruneRemoteName string `git:"lfs.pruneremotetocheck"` }
FetchPruneConfig collects together the config options that control fetching and pruning
type Fetcher ¶ added in v1.4.0
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 ¶ added in v1.4.0
func UniqMapFetcher ¶
type GitConfig ¶ added in v1.4.0
func NewGitConfig ¶ added in v1.4.0
type GitFetcher ¶ added in v1.4.0
type GitFetcher struct {
// contains filtered or unexported fields
}
func ReadGitConfig ¶ added in v1.4.0
func (*GitFetcher) All ¶ added in v1.5.0
func (g *GitFetcher) All() map[string][]string
func (*GitFetcher) Get ¶ added in v1.4.0
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 ¶ added in v1.4.0
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 NewOsFetcher ¶ added in v1.4.0
func NewOsFetcher() *OsFetcher
NewOsFetcher returns a new *OsFetcher.
func (*OsFetcher) Get ¶ added in v1.4.0
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 ¶ added in v1.4.0
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.