add Set(), remove .gitConfig
This commit is contained in:
parent
e2ca1e5533
commit
0e679c7d98
@ -57,8 +57,6 @@ type Configuration struct {
|
||||
// configuration.
|
||||
Git Environment
|
||||
|
||||
gitConfig map[string]string
|
||||
|
||||
CurrentRemote string
|
||||
NtlmSession ntlm.ClientSession
|
||||
envVars map[string]string
|
||||
@ -106,9 +104,8 @@ type Values struct {
|
||||
// This method should only be used during testing.
|
||||
func NewFrom(v Values) *Configuration {
|
||||
return &Configuration{
|
||||
Os: EnvironmentOf(mapFetcher(v.Os)),
|
||||
Git: EnvironmentOf(mapFetcher(v.Git)),
|
||||
gitConfig: v.Git,
|
||||
Os: EnvironmentOf(mapFetcher(v.Os)),
|
||||
Git: EnvironmentOf(mapFetcher(v.Git)),
|
||||
|
||||
envVars: make(map[string]string, 0),
|
||||
}
|
||||
@ -349,16 +346,10 @@ func (c *Configuration) SetEndpointAccess(e Endpoint, authType string) {
|
||||
switch authType {
|
||||
case "", "none":
|
||||
git.Config.UnsetLocalKey("", key)
|
||||
|
||||
c.loading.Lock()
|
||||
c.Git.Del(key)
|
||||
c.loading.Unlock()
|
||||
default:
|
||||
git.Config.SetLocal("", key, authType)
|
||||
|
||||
c.loading.Lock()
|
||||
c.gitConfig[strings.ToLower(key)] = authType
|
||||
c.loading.Unlock()
|
||||
c.Git.Set(key, authType)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ type Environment interface {
|
||||
Int(key string, def int) (val int)
|
||||
|
||||
All() map[string]string
|
||||
Set(key, value string)
|
||||
Del(key string)
|
||||
}
|
||||
|
||||
@ -91,6 +92,10 @@ func (e *environment) All() map[string]string {
|
||||
return e.Fetcher.All()
|
||||
}
|
||||
|
||||
func (e *environment) Set(key, value string) {
|
||||
e.Fetcher.Set(key, value)
|
||||
}
|
||||
|
||||
func (e *environment) Del(key string) {
|
||||
e.Fetcher.Del(key)
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ type Fetcher interface {
|
||||
// determining if the key exists.
|
||||
Get(key string) (val string, ok bool)
|
||||
|
||||
Set(key, value string)
|
||||
|
||||
All() map[string]string
|
||||
|
||||
Del(key string)
|
||||
|
@ -43,6 +43,12 @@ func (g *gitEnvironment) All() map[string]string {
|
||||
return g.git.All()
|
||||
}
|
||||
|
||||
func (g *gitEnvironment) Set(key, value string) {
|
||||
g.loadGitConfig()
|
||||
|
||||
g.git.Set(key, value)
|
||||
}
|
||||
|
||||
func (g *gitEnvironment) Del(key string) {
|
||||
g.loadGitConfig()
|
||||
|
||||
@ -68,7 +74,6 @@ func (g *gitEnvironment) loadGitConfig() bool {
|
||||
|
||||
g.git = EnvironmentOf(gf)
|
||||
|
||||
g.config.gitConfig = gf.vals // XXX TERRIBLE
|
||||
g.config.extensions = extensions
|
||||
|
||||
g.config.remotes = make([]string, 0, len(uniqRemotes))
|
||||
|
@ -139,6 +139,12 @@ func (g *GitFetcher) All() map[string]string {
|
||||
return newmap
|
||||
}
|
||||
|
||||
func (g *GitFetcher) Set(key, value string) {
|
||||
g.vmu.RLock()
|
||||
defer g.vmu.RUnlock()
|
||||
g.vals[strings.ToLower(key)] = value
|
||||
}
|
||||
|
||||
func (g *GitFetcher) Del(key string) {
|
||||
g.vmu.RLock()
|
||||
defer g.vmu.RUnlock()
|
||||
|
@ -22,6 +22,10 @@ func (m mapFetcher) All() map[string]string {
|
||||
return newmap
|
||||
}
|
||||
|
||||
func (m mapFetcher) Set(key, value string) {
|
||||
m[key] = value
|
||||
}
|
||||
|
||||
func (m mapFetcher) Del(key string) {
|
||||
delete(m, key)
|
||||
}
|
||||
|
@ -58,4 +58,6 @@ func (o *OsFetcher) All() map[string]string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (o *OsFetcher) Set(key, value string) {}
|
||||
|
||||
func (o *OsFetcher) Del(key string) {}
|
||||
|
Loading…
Reference in New Issue
Block a user