1
0
Fork 0

bin: Add -f/--force flag to git-branch-prune

This commit is contained in:
Jeremy Kaplan 2020-10-10 20:47:39 -07:00
commit 6fe8b6a7f8

View file

@ -10,6 +10,24 @@ export USAGE='<remote>
set -euo pipefail set -euo pipefail
POSITIONAL=()
FORCE=0
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-f|--force)
FORCE=1
shift
;;
*)
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
case "$#" in case "$#" in
0) 0)
remote='origin' remote='origin'
@ -33,6 +51,13 @@ if [ -z "${pruned_branches}" ]; then
exit 0 exit 0
fi fi
vipe <<< "${pruned_branches}" | \
if [ "${FORCE}" -eq 1 ]; then
selector='cat'
else
selector='vipe'
fi
"${selector}" <<< "${pruned_branches}" | \
awk '{print $1}' | \ awk '{print $1}' | \
xargs git branch -D xargs git branch -D