|
17 | 17 | merged=$(git branch --no-color --merged master | grep -v master | sed 's/\*/ /') |
18 | 18 |
|
19 | 19 | if [ ! -z "$merged" ] ; then |
20 | | - echo "Deleting the following merged branches:" |
21 | | - for branch in $merged ; do |
22 | | - echo " " "$branch" |
23 | | - done |
| 20 | + echo "Deleting the following merged branches:" |
| 21 | + for branch in $merged ; do |
| 22 | + echo " " "$branch" |
| 23 | + done |
24 | 24 |
|
25 | | - all=n |
| 25 | + all=n |
| 26 | + delete=n |
| 27 | + for branch in $merged ; do |
| 28 | + if [ $all = 'n' ] ; then |
26 | 29 | delete=n |
27 | | - for branch in $merged ; do |
28 | | - if [ $all = 'n' ] ; then |
29 | | - delete=n |
30 | | - # shellcheck disable=SC2162 |
31 | | - read -p "Delete $branch (y=yes, n=no, a=all)? " prompt |
32 | | - echo "all=$all delete=$delete prompt=$prompt" |
33 | | - if [ "$prompt" = 'a' ] ; then |
34 | | - delete=y |
35 | | - all=y |
36 | | - elif [ "$prompt" = 'y' ]; then |
37 | | - delete=y |
38 | | - fi |
| 30 | + # shellcheck disable=SC2162 |
| 31 | + read -p "Delete $branch (y=yes, n=no, a=all)? " prompt |
| 32 | + echo "all=$all delete=$delete prompt=$prompt" |
| 33 | + if [ "$prompt" = 'a' ] ; then |
| 34 | + delete=y |
| 35 | + all=y |
| 36 | + elif [ "$prompt" = 'y' ]; then |
| 37 | + delete=y |
39 | 38 | fi |
| 39 | + fi |
40 | 40 |
|
41 | | - if [ "$delete" = 'y' ] ; then |
42 | | - git branch -d "$branch" |
43 | | - fi |
44 | | - done |
| 41 | + if [ "$delete" = 'y' ] ; then |
| 42 | + git branch -d "$branch" |
| 43 | + fi |
| 44 | + done |
45 | 45 | fi |
46 | 46 |
|
47 | 47 | remotes=$(git remote) |
48 | 48 | for remote in $remotes ; do |
49 | | - prompt=n |
50 | | - # shellcheck disable=SC2162 |
51 | | - read -p "Prune deleted branches from remote '$remote' (y=yes n=no)? " prompt |
52 | | - if [ "$prompt" = 'y' ] ; then |
53 | | - git remote prune "$remote" |
54 | | - fi |
| 49 | + prompt=n |
| 50 | + # shellcheck disable=SC2162 |
| 51 | + read -p "Prune deleted branches from remote '$remote' (y=yes n=no)? " prompt |
| 52 | + if [ "$prompt" = 'y' ] ; then |
| 53 | + git remote prune "$remote" |
| 54 | + fi |
55 | 55 | done |
0 commit comments