fix(team,repo,org,wiki,auth): detect a kept admin permission, validate topics up front, page public members, name disabled wikis, treat auth switch's account as --user

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-18 20:40:25 +02:00
1 parent 339527b26c
commit dd2ec74d96
12 files changed
+289 -64

No files matched your search

+17 -8
View File
@@ -655,6 +655,9 @@ selects another. With two accounts, tea auth switch toggles between them; with m
asks which one on a terminal.`,
Example: "$ tea auth switch\n$ tea auth switch bob\n$ tea auth switch bob --host gitea.com",
RunE: func(cmd *cobra.Command, args []string) error {
if err := a.positionalAccount(args); err != nil {
return err
}
t, err := a.instanceTarget(cmd.Context())
if err != nil {
return err
@@ -665,9 +668,6 @@ asks which one on a terminal.`,
}
names := slices.Sorted(maps.Keys(users))
requested := a.options.user
if len(args) == 1 {
requested = args[0]
}
var user string
switch {
case requested != "":
@@ -710,6 +710,18 @@ asks which one on a terminal.`,
}
}
// positionalAccount treats the account argument of auth switch and auth logout like --user.
func (a *application) positionalAccount(args []string) error {
if len(args) == 0 {
return nil
}
if a.options.user != "" && !strings.EqualFold(a.options.user, args[0]) {
return clierr.Wrap(clierr.Usage, fmt.Errorf("--user %s and the account %s differ", a.options.user, args[0]))
}
a.options.user = args[0]
return nil
}
// chooseAccount asks which of the accounts of instance to use, or explains how to name one.
func (a *application) chooseAccount(cmd *cobra.Command, instance string, names []string, active string) (string, error) {
chooser, ok := a.chooser()
@@ -735,11 +747,8 @@ other credential helpers are asked to forget what they stored for the account on
instance, such as a copy of its token that a keychain kept after a push.`,
Example: "$ tea auth logout\n$ tea auth logout bob --host gitea.com\n# Without confirmation\n$ tea auth logout alice --yes",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 1 {
if a.options.user != "" && !strings.EqualFold(a.options.user, args[0]) {
return clierr.Wrap(clierr.Usage, fmt.Errorf("--user %s and the account %s differ", a.options.user, args[0]))
}
a.options.user = args[0]
if err := a.positionalAccount(args); err != nil {
return err
}
t, err := a.instanceTarget(cmd.Context())
if err != nil {