Ver código fonte

CurrentUser should always return the flag if set

previously when the user flag was provided, the function would still try
to get a user from config. flag should take precedence
pull/36/head
Rob Loranger 4 anos atrás
pai
commit
abc78c7652
Nenhuma chave conhecida encontrada para esta assinatura no banco de dados ID da chave GPG: D6F1633A4F0903B8
1 arquivos alterados com 5 adições e 5 exclusões
  1. +5
    -5
      config/user.go

+ 5
- 5
config/user.go Ver arquivo

@@ -136,6 +136,11 @@ func UserHostDir(c *cli.Context) (string, error) {
// CurrentUser returns the username of the user taking action in the current // CurrentUser returns the username of the user taking action in the current
// cli.Context. // cli.Context.
func CurrentUser(c *cli.Context) (string, error) { func CurrentUser(c *cli.Context) (string, error) {
// Use user flag value
if c.GlobalString("user") != "" {
return c.GlobalString("user"), nil
}

// Load host-level config, if host flag is set // Load host-level config, if host flag is set
hostDir, err := UserHostDir(c) hostDir, err := UserHostDir(c)
if err != nil { if err != nil {
@@ -160,10 +165,5 @@ func CurrentUser(c *cli.Context) (string, error) {
} }
} }


// Use user flag value
if c.GlobalString("user") != "" {
return c.GlobalString("user"), nil
}

return cfg.Default.User, nil return cfg.Default.User, nil
} }

Carregando…
Cancelar
Salvar