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