2
2
3
3
# Setup.
4
4
VERSION=" 0.2.3"
5
+ BRANCH_PREFIX=" fire-"
5
6
6
7
version () {
7
8
printf " git-fire version %s\n" " $VERSION "
@@ -23,7 +24,7 @@ user_email() {
23
24
}
24
25
25
26
new_branch () {
26
- echo " fire -${1:- $(current_branch)} -$( user_email) -$( current_epoch) "
27
+ echo " $BRANCH_PREFIX -${1:- $(current_branch)} -$( user_email) -$( current_epoch) "
27
28
}
28
29
29
30
fire () {
@@ -57,6 +58,27 @@ fire() {
57
58
printf " \n\nLeave building!\n"
58
59
}
59
60
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
+
60
82
display_help () {
61
83
cat << -EOF
62
84
@@ -71,6 +93,7 @@ display_help() {
71
93
options:
72
94
-V, --version Output current version of git-fire
73
95
-h, --help Display this help information
96
+ -d, --delete Delete branches prefixed with "$BRANCH_PREFIX "
74
97
75
98
EOF
76
99
exit 0
80
103
case $1 in
81
104
-V|--version) version; exit 0 ;;
82
105
-h|--help) display_help; exit 0 ;;
106
+ -d|--delete) delete_fire_branches; exit 0 ;;
83
107
esac
84
108
85
109
fire " $@ "
0 commit comments