Ver a proveniência

CurrentUser only use global when needed

by needed: when host flag was supplied, matches that configured and a
user is set in config as well. they should be a pair.
pull/36/head
Rob Loranger há 4 anos
ascendente
cometimento
55dcf5e79c
Não foi encontrada uma chave conhecida para esta assinatura, na base de dados ID da chave GPG: D6F1633A4F0903B8
1 ficheiros alterados com 8 adições e 1 eliminações
  1. +8
    -1
      config/user.go

+ 8
- 1
config/user.go Ver ficheiro

@@ -147,10 +147,17 @@ func CurrentUser(c *cli.Context) (string, error) {
}
if cfg.Default.User == "" {
// Load app-level config
cfg, err = LoadConfig(UserDataDir(c.App.ExtraInfo()["configDir"]))
globalCFG, err := LoadConfig(UserDataDir(c.App.ExtraInfo()["configDir"]))
if err != nil {
return "", err
}
// only user global defaults when both are set and hosts match
if globalCFG.Default.User != "" &&
globalCFG.Default.Host != "" &&
c.GlobalIsSet("host") &&
globalCFG.Default.Host == c.GlobalString("host") {
cfg = globalCFG
}
}

// Use user flag value


Carregando…
Cancelar
Guardar