Skip to content

Commit

Permalink
Fix merge conflicts for #20
Browse files Browse the repository at this point in the history
  • Loading branch information
qw3rtman committed Aug 18, 2017
1 parent d72b68e commit 6c67467
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion git-fire
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Setup.
VERSION="0.2.3"
BRANCH_PREFIX="fire-"

version() {
printf "git-fire version %s\n" "$VERSION"
Expand All @@ -23,7 +24,7 @@ user_email() {
}

new_branch() {
echo "fire-${1:-$(current_branch)}-$(user_email)-$(current_epoch)"
echo "$BRANCH_PREFIX-${1:-$(current_branch)}-$(user_email)-$(current_epoch)"
}

fire() {
Expand Down Expand Up @@ -57,6 +58,27 @@ fire() {
printf "\n\nLeave building!\n"
}

delete_fire_branches() {
all_branches=( $(git branch -a) )
for branch in "${all_branches[@]}"
do
for remote in $(git remote); do
if [[ $branch == remotes/$remote/$BRANCH_PREFIX* ]] ;
then
branch_without_remote_in_name="${branch/remotes\/$remote\//}"
echo "deleting remote " $remote $branch_without_remote_in_name
git push --delete $remote $branch_without_remote_in_name
fi
done

if [[ $branch == $BRANCH_PREFIX* ]] ;
then
echo "deleting local branch: $branch"
git branch -D $branch
fi
done
}

display_help() {
cat <<-EOF
Expand All @@ -71,6 +93,7 @@ display_help() {
options:
-V, --version Output current version of git-fire
-h, --help Display this help information
-d, --delete Delete branches prefixed with "$BRANCH_PREFIX"
EOF
exit 0
Expand All @@ -80,6 +103,7 @@ EOF
case $1 in
-V|--version) version; exit 0 ;;
-h|--help) display_help; exit 0 ;;
-d|--delete) delete_fire_branches; exit 0 ;;
esac

fire "$@"

0 comments on commit 6c67467

Please sign in to comment.