plan/scripts/cleanup-dry-run-refs.sh
0 → 100755
+170
−0
Loading
Per reviewer request: a standalone script the user can run after a
dry-run effort to identify (default) and optionally remove
(--apply) any tags or branches left on the remote with the
{dry-run-prefix}.
Usage:
./cleanup-dry-run-refs.sh # list-only, today's prefix
PREFIX=dry-run-2026-04-28 ./cleanup-dry-run-refs.sh # list specific
PREFIX=dry-run-2026-04-28 ./cleanup-dry-run-refs.sh --apply # delete
Behaviors:
- Cheap discovery via `git ls-remote {remote}`; no fetch.
- Strips ^{} peel suffix and dedups by ref-name (annotated tags
otherwise list twice with different SHAs — tag object + peeled
commit). Tested against the 2026-04-28 dry-run residue: shows
14 distinct refs as expected (was 15 before the dedup fix).
- In --apply mode: deletes remote refs first
(git push --delete), then local tracking refs (refs/heads/,
refs/tags/, refs/remotes/{remote}/). Continues on individual
delete failures and tallies summary at the end.
- Defaults: REMOTE=agentic, PREFIX=dry-run-<today-UTC>.
- Mode 700, set -uo pipefail, --help, exit 1 on bad arg, exit 2
on git ls-remote failure.
Complements the workers' protocol --delete pushes during normal
operation. Use this script after abnormal exits, killed sessions,
network blips during cleanup, or to sweep an old dry-run prefix
that no agent is currently watching.
Co-Authored-By:
Claude Opus 4.7 (1M context) <noreply@anthropic.com>