From 87e79cecdf3cd3cdffcb88bcb9b4fa833f2e9a24 Mon Sep 17 00:00:00 2001 From: "Rai (Michael Pokorny)" Date: Tue, 24 Jun 2025 22:43:45 -0700 Subject: [PATCH] manager_utils(dispose): use for-each-ref to list branches without decorations --- agentydragon/tools/manager_utils/agentydragon_task.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/agentydragon/tools/manager_utils/agentydragon_task.py b/agentydragon/tools/manager_utils/agentydragon_task.py index 95c8a53a4a..65d411dd1c 100644 --- a/agentydragon/tools/manager_utils/agentydragon_task.py +++ b/agentydragon/tools/manager_utils/agentydragon_task.py @@ -201,15 +201,15 @@ def dispose(task_id): rel = wt_dir.relative_to(root) subprocess.run(['git', 'worktree', 'remove', str(rel), '--force'], cwd=root) # Delete any matching branches + # delete any matching local branches cleanly via for-each-ref + ref_pattern = f'refs/heads/agentydragon-{tid}-*' branches = subprocess.run( - ['git', 'branch', '--list', f'agentydragon-{tid}-*'], + ['git', 'for-each-ref', '--format=%(refname:short)', ref_pattern], capture_output=True, text=True, cwd=root ).stdout.splitlines() for br in branches: - # strip markers for current (*) or other worktrees (+) and whitespace - name = br.lstrip('*+ ').strip() - if name: - subprocess.run(['git', 'branch', '-D', name], cwd=root) + if br: + subprocess.run(['git', 'branch', '-D', br], cwd=root) click.echo(f'Disposed task {tid}') @cli.command()