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,27 @@ 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 == 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
+
52
74
display_help () {
53
75
cat << -EOF
54
76
@@ -63,6 +85,7 @@ display_help() {
63
85
options:
64
86
-V, --version Output current version of git-fire
65
87
-h, --help Display this help information
88
+ -d, --delete Delete branches prefixed with "$BRANCH_PREFIX "
66
89
67
90
EOF
68
91
exit 0
72
95
case $1 in
73
96
-V|--version) version; exit 0 ;;
74
97
-h|--help) display_help; exit 0 ;;
98
+ -d|--delete) delete_fire_branches; exit 0 ;;
75
99
esac
76
100
77
101
fire " $@ "
0 commit comments