From 1d35b96d86ad3c53e2575b374ae0c602dfef1a56 Mon Sep 17 00:00:00 2001 From: "Rai (Michael Pokorny)" Date: Tue, 24 Jun 2025 22:39:15 -0700 Subject: [PATCH] manager_utils: fix dispose to actually remove worktrees and branches --- .../tools/manager_utils/agentydragon_task.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/agentydragon/tools/manager_utils/agentydragon_task.py b/agentydragon/tools/manager_utils/agentydragon_task.py index b600bb2cd8..f90e102a95 100644 --- a/agentydragon/tools/manager_utils/agentydragon_task.py +++ b/agentydragon/tools/manager_utils/agentydragon_task.py @@ -192,12 +192,21 @@ def set_deps(task_id, deps): @click.argument('task_id', nargs=-1) def dispose(task_id): """Dispose worktree and delete branch for TASK_ID(s)""" + root = repo_root() + wt_base = task_dir() / '.worktrees' for tid in task_id: - branch = f'agentydragon-{tid}-*' - # remove worktree - subprocess.run(['git', 'worktree', 'remove', f'tasks/.worktrees/{tid}-*', '--force']) - # delete branch - subprocess.run(['git', 'branch', '-D', f'agentydragon-{tid}-*']) + # Remove any matching worktree directories + for wt_dir in wt_base.glob(f'{tid}-*'): + subprocess.run(['git', 'worktree', 'remove', str(wt_dir), '--force'], cwd=root) + # Delete any matching branches + branches = subprocess.run( + ['git', 'branch', '--list', f'agentydragon-{tid}-*'], + capture_output=True, text=True, cwd=root + ).stdout.splitlines() + for br in branches: + name = br.strip().lstrip('* ').strip() + if name: + subprocess.run(['git', 'branch', '-D', name], cwd=root) click.echo(f'Disposed task {tid}') @cli.command()