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:
Ross Golder
2025-10-27 17:52:04 +00:00
committed by Lunny Xiao
parent 3495ec5ed4
commit 81481f8f9d

View File

@@ -163,6 +163,8 @@ and then run your command again.`)
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)).
@@ -175,6 +177,7 @@ and then run your command again.`)
os.Exit(1)
}
}
}
// parse reposlug (owner falling back to login owner if reposlug contains only repo name)
c.Owner, c.Repo = utils.GetOwnerAndRepo(c.RepoSlug, c.Login.User)