22
33# Setup.
44VERSION=" 0.2.3"
5+ BRANCH_PREFIX=" fire-"
56
67version () {
78 printf " git-fire version %s\n" " $VERSION "
@@ -23,7 +24,7 @@ user_email() {
2324}
2425
2526new_branch () {
26- echo " fire -${1:- $(current_branch)} -$( user_email) -$( current_epoch) "
27+ echo " $BRANCH_PREFIX -${1:- $(current_branch)} -$( user_email) -$( current_epoch) "
2728}
2829
2930fire () {
@@ -57,6 +58,27 @@ fire() {
5758 printf " \n\nLeave building!\n"
5859}
5960
61+ delete_fire_branches () {
62+ all_branches=( $( git branch -a) )
63+ for branch in " ${all_branches[@]} "
64+ do
65+ for remote in $( git remote) ; do
66+ if [[ $branch == remotes/$remote /$BRANCH_PREFIX * ]] ;
67+ then
68+ branch_without_remote_in_name=" ${branch/ remotes\/ $remote \/ / } "
69+ echo " deleting remote " $remote $branch_without_remote_in_name
70+ git push --delete $remote $branch_without_remote_in_name
71+ fi
72+ done
73+
74+ if [[ $branch == $BRANCH_PREFIX * ]] ;
75+ then
76+ echo " deleting local branch: $branch "
77+ git branch -D $branch
78+ fi
79+ done
80+ }
81+
6082display_help () {
6183 cat << -EOF
6284
@@ -71,6 +93,7 @@ display_help() {
7193 options:
7294 -V, --version Output current version of git-fire
7395 -h, --help Display this help information
96+ -d, --delete Delete branches prefixed with "$BRANCH_PREFIX "
7497
7598EOF
7699 exit 0
80103case $1 in
81104 -V|--version) version; exit 0 ;;
82105 -h|--help) display_help; exit 0 ;;
106+ -d|--delete) delete_fire_branches; exit 0 ;;
83107esac
84108
85109fire " $@ "
0 commit comments