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,27 @@ 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 == remotes/$remote /$BRANCH_PREFIX * ]] ;
59+ then
60+ branch_without_remote_in_name=" ${branch/ remotes\/ $remote \/ / } "
61+ echo " deleting remote " $remote $branch_without_remote_in_name
62+ git push --delete $remote $branch_without_remote_in_name
63+ fi
64+ done
65+
66+ if [[ $branch == $BRANCH_PREFIX * ]] ;
67+ then
68+ echo " deleting local branch: $branch "
69+ git branch -D $branch
70+ fi
71+ done
72+ }
73+
5274display_help () {
5375 cat << -EOF
5476
@@ -63,6 +85,7 @@ display_help() {
6385 options:
6486 -V, --version Output current version of git-fire
6587 -h, --help Display this help information
88+ -d, --delete Delete branches prefixed with "$BRANCH_PREFIX "
6689
6790EOF
6891 exit 0
7295case $1 in
7396 -V|--version) version; exit 0 ;;
7497 -h|--help) display_help; exit 0 ;;
98+ -d|--delete) delete_fire_branches; exit 0 ;;
7599esac
76100
77101fire " $@ "
0 commit comments