22
33# Setup.
44VERSION=" 0.0.1"
5+ BRANCH_PREFIX=" fire-"
56
67version () {
78 printf " git-fire version %s\n" " $VERSION "
@@ -23,12 +24,12 @@ user_email() {
2324}
2425
2526new_branch () {
26- echo " fire- $( current_branch) -$( user_email) -$( current_epoch) "
27+ echo " $BRANCH_PREFIX $( current_branch) -$( user_email) -$( current_epoch) "
2728}
2829
2930fire () {
3031 git checkout -b " $( new_branch) "
31-
32+
3233 # cd to git root directory
3334 cd " $( git rev-parse --show-toplevel) "
3435
@@ -49,6 +50,26 @@ fire() {
4950 printf " \n\nLeave building!\n"
5051}
5152
53+ delete_fire_branches () {
54+ all_branches=( $( git branch -a) )
55+ for branch in " ${all_branches[@]} "
56+ do
57+ for remote in $( git remote) ; do
58+ if [[ $branch == $remote /$BRANCH_PREFIX * ]] ;
59+ then
60+ branch_without_remote_in_name=" ${branch/ $remote \/ / } "
61+ git push --delete $remote $branch_without_remote_in_name
62+ fi
63+ done
64+
65+ if [[ $branch == $BRANCH_PREFIX * ]] ;
66+ then
67+ echo " deleting local branch: $branch "
68+ git branch -D $branch
69+ fi
70+ done
71+ }
72+
5273display_help () {
5374 cat << -EOF
5475
@@ -63,15 +84,16 @@ display_help() {
6384 options:
6485 -V, --version Output current version of git-fire
6586 -h, --help Display this help information
87+ -d, --delete Delete branches prefixed with "$BRANCH_PREFIX "
6688
6789EOF
6890 exit 0
6991}
7092
71-
7293case $1 in
7394 -V|--version) version; exit 0 ;;
7495 -h|--help) display_help; exit 0 ;;
96+ -d|--delete) delete_fire_branches; exit 0 ;;
7597esac
7698
7799fire " $@ "
0 commit comments