File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,12 +6,17 @@ set -eu -o pipefail
66
77git fetch --prune & > /dev/null
88
9- for branch in $( git branch -vv | grep -o -E ' ^[\* ]+\S+' | tr -d ' * ' ) ; do
10- upstream=$( git rev-parse --abbrev-ref --symbolic-full-name " ${branch} @{upstream}" 2> /dev/null)
11- if [ -n " ${upstream} " ]; then
12- if ! git show-ref --quiet " refs/remotes/${upstream} " ; then
9+ current_branch=$( git symbolic-ref --quiet --short HEAD || true)
10+
11+ git branch --format=' %(refname:short)%09%(upstream:track)' |
12+ while IFS=$' \t ' read -r branch upstream_track; do
13+ if [ " ${upstream_track} " = " [gone]" ]; then
14+ if [ " ${branch} " = " ${current_branch} " ]; then
15+ echo " Skipping current branch '${branch} '"
16+ continue
17+ fi
18+
1319 echo " Deleting branch '${branch} '"
1420 git branch -D " ${branch} "
1521 fi
16- fi
17- done
22+ done
You can’t perform that action at this time.
0 commit comments