summaryrefslogtreecommitdiff
path: root/bin/clean-patch-queues
blob: 08ca4866fbcdedc8cf036333654a04d93bd7b875 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

. "$HOME/.shenv"
. "$HOME/lib/tputfs.sh"

if [ ! "$1" = "-y" ]; then
    status Are you sure you want to delete ALL git branches matching
    status "patch-queue/* in all git repos matching ~/src/* ?"
    status Press enter to confirm or hit C-c to abort
    read _
fi

for repo in $HOME/src/*; do
    if [ -d "$repo/.git" ]; then
        cd "$repo"
        branches="$(git branch | grep '  patch-queue/*' | cut -c3-)"
        for branch in $branches; do
            git branch -D "$branch"
            echo "  in repo $(basename $repo)"
        done
    fi
done