git-lfs/config/config_netrc.go
Taylor Blau 4593d0a641 vendor: vendor dependencies in vendor/ using Glide
- script/vendor received an update in order to work with Glide
- import paths have been rewritten to work with GO15VENDOREXPERIMENT
2016-05-23 12:10:35 -06:00

33 lines
559 B
Go

package config
import (
"os"
"path/filepath"
"github.com/bgentry/go-netrc/netrc"
)
type netrcfinder interface {
FindMachine(string) *netrc.Machine
}
type noNetrc struct{}
func (n *noNetrc) FindMachine(host string) *netrc.Machine {
return nil
}
func (c *Configuration) parseNetrc() (netrcfinder, error) {
home := c.Getenv("HOME")
if len(home) == 0 {
return &noNetrc{}, nil
}
nrcfilename := filepath.Join(home, netrcBasename)
if _, err := os.Stat(nrcfilename); err != nil {
return &noNetrc{}, nil
}
return netrc.ParseFile(nrcfilename)
}