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

+13 -2
View File
@@ -164,13 +164,24 @@ func (a *application) addRepositoryMutations(group *cobra.Command) {
if err != nil {
return err
}
if err := a.confirm(cmd, verb+" "+t.Host+"/"+t.Repo); err != nil {
return err
inferred := ""
if t.RepoSource != "--repo" {
source := strings.Replace(t.RepoSource, "remote ", "git remote ", 1)
if a.options.yes {
return clierr.Wrap(clierr.Usage, fmt.Errorf("--yes requires an explicit repository, not one inferred from %s: tea repo %s %s --yes", source, verb, t.Repo))
}
inferred = " (from " + source + ")"
}
service := services.Repositories{Client: t.client}
if verb == "delete" {
if err := a.confirmTyped(cmd, "Delete "+t.Repo+inferred+"? This cannot be undone.", t.Repo); err != nil {
return err
}
return service.Delete(cmd.Context(), t.Repo)
}
if err := a.confirm(cmd, "Archive "+t.Repo+inferred+"?"); err != nil {
return err
}
archived := true
item, err := service.Edit(cmd.Context(), t.Repo, services.RepositoryEdit{Archived: &archived})
if err != nil {