fix(repo): require an explicit repository to delete or archive with --yes

In a clone of a fork, repository discovery prefers the upstream remote,
so `tea repo delete --yes` deleted the parent repository. With --yes,
repo delete and repo archive now require the repository as an argument
or --repo. Interactively, repo delete asks the user to type the
repository name, and both prompts say where an inferred repository
came from.

Signed-off-by: bircni <bircni@icloud.com>
This commit is contained in:
bircni committed 2026-10-11 21:43:32 +02:00
1 parent 4ea16c6510
commit b3dc3f47cb
3 files changed
+109 -2

No files matched your search

+22
View File
@@ -288,6 +288,28 @@ func (a *application) confirm(cmd *cobra.Command, description string) error {
return terminal.Confirm(cmd.Context(), description, a.options.yes, a.deps.Streams, a.policy(s), a.deps.Prompter)
}
// confirmTyped asks the user to type answer before an irreversible action unless --yes was supplied.
func (a *application) confirmTyped(cmd *cobra.Command, description, answer string) error {
if a.options.yes {
return nil
}
s, err := a.deps.Settings.Load()
if err != nil {
return err
}
if !a.policy(s).CanPrompt(a.deps.Streams) {
return clierr.Wrap(clierr.Usage, errors.New("confirmation required: supply --yes"))
}
typed, err := a.deps.Prompter.Input(cmd.Context(), description+" Type "+answer+" to confirm:")
if err != nil {
return err
}
if !strings.EqualFold(strings.TrimSpace(typed), answer) {
return clierr.Wrap(clierr.Canceled, errors.New("operation canceled"))
}
return nil
}
// require prompts for a missing required value under the prompt policy.
func (a *application) require(cmd *cobra.Command, value *string, flag string) (bool, error) {
s, err := a.deps.Settings.Load()