From 81481f8f9de3e1793cd6a6ee759e3e0e79e5b864 Mon Sep 17 00:00:00 2001 From: Ross Golder Date: Mon, 27 Oct 2025 17:52:04 +0000 Subject: [PATCH] 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 Co-authored-by: Ross Golder Co-committed-by: Ross Golder --- modules/context/context.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/modules/context/context.go b/modules/context/context.go index 2e3ab85..1a2a61d 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -163,16 +163,19 @@ and then run your command again.`) os.Exit(1) } - fallback := false - if err := huh.NewConfirm(). - Title(fmt.Sprintf("NOTE: no gitea login detected, whether falling back to login '%s'?", c.Login.Name)). - Value(&fallback). - WithTheme(theme.GetTheme()). - Run(); err != nil { - log.Fatalf("Get confirm failed: %v", err) - } - if !fallback { - os.Exit(1) + // Only prompt for confirmation if the fallback login is not explicitly set as default + if !c.Login.Default { + fallback := false + if err := huh.NewConfirm(). + Title(fmt.Sprintf("NOTE: no gitea login detected, whether falling back to login '%s'?", c.Login.Name)). + Value(&fallback). + WithTheme(theme.GetTheme()). + Run(); err != nil { + log.Fatalf("Get confirm failed: %v", err) + } + if !fallback { + os.Exit(1) + } } }