2
2
3
3
# Setup.
4
4
VERSION=" 0.0.1"
5
+ BRANCH_PREFIX=" fire-"
5
6
6
7
version () {
7
8
printf " git-fire version %s\n" " $VERSION "
@@ -23,12 +24,12 @@ user_email() {
23
24
}
24
25
25
26
new_branch () {
26
- echo " fire- $( current_branch) -$( user_email) -$( current_epoch) "
27
+ echo " $BRANCH_PREFIX $( current_branch) -$( user_email) -$( current_epoch) "
27
28
}
28
29
29
30
fire () {
30
31
git checkout -b " $( new_branch) "
31
-
32
+
32
33
# cd to git root directory
33
34
cd " $( git rev-parse --show-toplevel) "
34
35
@@ -49,6 +50,26 @@ fire() {
49
50
printf " \n\nLeave building!\n"
50
51
}
51
52
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
+
52
73
display_help () {
53
74
cat << -EOF
54
75
@@ -63,15 +84,16 @@ display_help() {
63
84
options:
64
85
-V, --version Output current version of git-fire
65
86
-h, --help Display this help information
87
+ -d, --delete Delete branches prefixed with "$BRANCH_PREFIX "
66
88
67
89
EOF
68
90
exit 0
69
91
}
70
92
71
-
72
93
case $1 in
73
94
-V|--version) version; exit 0 ;;
74
95
-h|--help) display_help; exit 0 ;;
96
+ -d|--delete) delete_fire_branches; exit 0 ;;
75
97
esac
76
98
77
99
fire " $@ "
0 commit comments