manager_utils: fix dispose to actually remove worktrees and branches

This commit is contained in:
Rai (Michael Pokorny)
2025-06-24 22:39:15 -07:00
parent cc65aa0882
commit 1d35b96d86

View File

@@ -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()