f11bb607c5
so we don't suggest deleting remote branches when `git rev-parse` failed. For example, it could fail if a remote tracking branch is gone.
14 lines
449 B
Bash
14 lines
449 B
Bash
# vim:et sts=2 sw=2 ft=zsh
|
|
local -a remotes
|
|
if (( ${*[(I)(-r|--remotes)]} )); then
|
|
remotes=(${^*:#-*})
|
|
else
|
|
remotes=(${(f)"$(command git rev-parse --abbrev-ref ${^*:#-*}@{u} 2>/dev/null)"}) || remotes=()
|
|
fi
|
|
if command git branch --delete ${@} && \
|
|
(( ${#remotes[@]} )) && \
|
|
read -q "?Also delete remote branch(es) ${remotes} [y/N]? "; then
|
|
print
|
|
local remote
|
|
for remote (${remotes}) command git push ${remote%%/*} :${remote#*/}
|
|
fi
|