Переглянути джерело

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 4 роки тому
джерело
коміт
55dcf5e79c
Не вдалося знайти GPG ключ що відповідає даному підпису Ідентифікатор GPG ключа: D6F1633A4F0903B8
1 змінених файлів з 8 додано та 1 видалено
  1. +8
    -1
      config/user.go

+ 8
- 1
config/user.go Переглянути файл

@@ -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


Завантаження…
Відмінити
Зберегти