config.etc: remove Getenv utility method

This commit is contained in:
Taylor Blau 2016-08-10 14:23:03 -06:00
parent ec501991a4
commit 254c11d179
8 changed files with 19 additions and 20 deletions

@ -69,8 +69,9 @@ func sshGetExeAndArgs(cfg *config.Configuration, endpoint config.Endpoint) (exe
isPlink := false
isTortoise := false
ssh := cfg.Getenv("GIT_SSH")
cmdArgs := strings.Fields(cfg.Getenv("GIT_SSH_COMMAND"))
ssh, _ := cfg.Os.Get("GIT_SSH")
sshCmd, _ := cfg.Os.Get("GIT_SSH_COMMAND")
cmdArgs := strings.Fields(sshCmd)
if len(cmdArgs) > 0 {
ssh = cmdArgs[0]
cmdArgs = cmdArgs[1:]

@ -120,7 +120,9 @@ func checkoutWithIncludeExclude(include []string, exclude []string) {
for _, pointer := range pointers {
totalBytes += pointer.Size
}
progress := progress.NewProgressMeter(len(pointers), totalBytes, false, cfg.Getenv("GIT_LFS_PROGRESS"))
logPath, _ := cfg.Os.Get("GIT_LFS_PROGRESS")
progress := progress.NewProgressMeter(len(pointers), totalBytes, false, logPath)
progress.Start()
totalBytes = 0
for _, pointer := range pointers {

@ -202,12 +202,6 @@ func (c *Configuration) parseTag(tag reflect.StructTag) (key string, env *Enviro
return
}
// Getenv is shorthand for `c.Os.Get(key)`.
func (c *Configuration) Getenv(key string) string {
v, _ := c.Os.Get(key)
return v
}
// GitRemoteUrl returns the git clone/push url for a given remote (blank if not found)
// the forpush argument is to cater for separate remote.name.pushurl settings
func (c *Configuration) GitRemoteUrl(remote string, forpush bool) string {

@ -18,7 +18,7 @@ func (n *noNetrc) FindMachine(host string) *netrc.Machine {
}
func (c *Configuration) parseNetrc() (netrcfinder, error) {
home := c.Getenv("HOME")
home, _ := c.Os.Get("HOME")
if len(home) == 0 {
return &noNetrc{}, nil
}

@ -48,7 +48,7 @@ func appendRootCAsForHostFromGitconfig(cfg *config.Configuration, pool *x509.Cer
// Accumulate certs from all these locations:
// GIT_SSL_CAINFO first
if cafile := cfg.Getenv("GIT_SSL_CAINFO"); len(cafile) > 0 {
if cafile, _ := cfg.Os.Get("GIT_SSL_CAINFO"); len(cafile) > 0 {
return appendCertsFromFile(pool, cafile)
}
// http.<url>/.sslcainfo or http.<url>.sslcainfo
@ -66,7 +66,7 @@ func appendRootCAsForHostFromGitconfig(cfg *config.Configuration, pool *x509.Cer
return appendCertsFromFile(pool, cafile)
}
// GIT_SSL_CAPATH
if cadir := cfg.Getenv("GIT_SSL_CAPATH"); len(cadir) > 0 {
if cadir, _ := cfg.Os.Get("GIT_SSL_CAPATH"); len(cadir) > 0 {
return appendCertsFromFilesInDir(pool, cadir)
}
// http.sslcapath

@ -20,24 +20,24 @@ func ProxyFromGitConfigOrEnvironment(c *config.Configuration) func(req *http.Req
}
if len(https_proxy) == 0 {
https_proxy = c.Getenv("HTTPS_PROXY")
https_proxy, _ = c.Os.Get("HTTPS_PROXY")
}
if len(https_proxy) == 0 {
https_proxy = c.Getenv("https_proxy")
https_proxy, _ = c.Os.Get("https_proxy")
}
if len(http_proxy) == 0 {
http_proxy = c.Getenv("HTTP_PROXY")
http_proxy, _ = c.Os.Get("HTTP_PROXY")
}
if len(http_proxy) == 0 {
http_proxy = c.Getenv("http_proxy")
http_proxy, _ = c.Os.Get("http_proxy")
}
no_proxy := c.Getenv("NO_PROXY")
no_proxy, _ := c.Os.Get("NO_PROXY")
if len(no_proxy) == 0 {
no_proxy = c.Getenv("no_proxy")
no_proxy, _ = c.Os.Get("no_proxy")
}
return func(req *http.Request) (*url.URL, error) {

@ -58,10 +58,12 @@ type TransferQueue struct {
// newTransferQueue builds a TransferQueue, direction and underlying mechanism determined by adapter
func newTransferQueue(files int, size int64, dryRun bool, dir transfer.Direction) *TransferQueue {
logPath, _ := config.Config.Os.Get("GIT_LFS_PROGRESS")
q := &TransferQueue{
direction: dir,
dryRun: dryRun,
meter: progress.NewProgressMeter(files, size, dryRun, config.Config.Getenv("GIT_LFS_PROGRESS")),
meter: progress.NewProgressMeter(files, size, dryRun, logPath),
apic: make(chan Transferable, batchSize),
retriesc: make(chan Transferable, batchSize),
errorc: make(chan error),

@ -27,7 +27,7 @@ const (
var currentPlatform = PlatformUndetermined
func CopyCallbackFile(event, filename string, index, totalFiles int) (progress.CopyCallback, *os.File, error) {
logPath := config.Config.Getenv("GIT_LFS_PROGRESS")
logPath, _ := config.Config.Os.Get("GIT_LFS_PROGRESS")
if len(logPath) == 0 || len(filename) == 0 || len(event) == 0 {
return nil, nil, nil
}