Skip to content

Commit 6c67467

Browse files
committed
Fix merge conflicts for #20
1 parent d72b68e commit 6c67467

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

git-fire

+25-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Setup.
44
VERSION="0.2.3"
5+
BRANCH_PREFIX="fire-"
56

67
version() {
78
printf "git-fire version %s\n" "$VERSION"
@@ -23,7 +24,7 @@ user_email() {
2324
}
2425

2526
new_branch() {
26-
echo "fire-${1:-$(current_branch)}-$(user_email)-$(current_epoch)"
27+
echo "$BRANCH_PREFIX-${1:-$(current_branch)}-$(user_email)-$(current_epoch)"
2728
}
2829

2930
fire() {
@@ -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+
6082
display_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
7598
EOF
7699
exit 0
@@ -80,6 +103,7 @@ EOF
80103
case $1 in
81104
-V|--version) version; exit 0 ;;
82105
-h|--help) display_help; exit 0 ;;
106+
-d|--delete) delete_fire_branches; exit 0 ;;
83107
esac
84108

85109
fire "$@"

0 commit comments

Comments
 (0)