mirror of
https://gitea.com/gitea/tea.git
synced 2025-10-30 08:45:28 +01:00
Fix: Only prompt for login confirmation when no default login is set (#839)
When running tea commands outside of a repository context, tea falls back to using the default login but always prompted for confirmation, even when a default was set. This fix only prompts when no default is configured. Reviewed-on: https://gitea.com/gitea/tea/pulls/839 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Ross Golder <ross@golder.org> Co-committed-by: Ross Golder <ross@golder.org>
This commit is contained in:
@@ -163,16 +163,19 @@ and then run your command again.`)
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fallback := false
|
// Only prompt for confirmation if the fallback login is not explicitly set as default
|
||||||
if err := huh.NewConfirm().
|
if !c.Login.Default {
|
||||||
Title(fmt.Sprintf("NOTE: no gitea login detected, whether falling back to login '%s'?", c.Login.Name)).
|
fallback := false
|
||||||
Value(&fallback).
|
if err := huh.NewConfirm().
|
||||||
WithTheme(theme.GetTheme()).
|
Title(fmt.Sprintf("NOTE: no gitea login detected, whether falling back to login '%s'?", c.Login.Name)).
|
||||||
Run(); err != nil {
|
Value(&fallback).
|
||||||
log.Fatalf("Get confirm failed: %v", err)
|
WithTheme(theme.GetTheme()).
|
||||||
}
|
Run(); err != nil {
|
||||||
if !fallback {
|
log.Fatalf("Get confirm failed: %v", err)
|
||||||
os.Exit(1)
|
}
|
||||||
|
if !fallback {
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user