1
0
Fork 0
mirror of synced 2024-11-22 23:35:35 -05:00

[git] Add git-branch-delete-interactive

that prompts if upstream remote branch(es) should be deleted too. As
with `git branch`, the function supports multiple branches as params,
and also the `-r`/`--remotes` param. Update `gbx` and `gbX` to use this
function.

Also update `git-stash-clear-interactive` to have multiple tests instead
of multiple nested `if`/`then`/`fi`. (Simpler syntax, IMHO)
This commit is contained in:
Eric Nielsen 2018-02-05 10:44:59 -05:00
parent e9171405cf
commit 451e51bd88
3 changed files with 22 additions and 6 deletions

View file

@ -0,0 +1,16 @@
# vim:et sts=2 sw=2 ft=zsh
local -a remotes
if (( ${*[(I)-r]} || ${*[(I)--remotes]} )); then
remotes=(${^*:#-*})
else
remotes=(${(f)"$(command git rev-parse --abbrev-ref ${^*:#-*}@{u} 2>/dev/null)"})
fi
if command git branch --delete ${@} && \
(( ${#remotes[@]} )) && \
read -q "?Also delete remote branch(es) ${remotes} [y/N]? "; then
print
local remote
for remote (${remotes}); do
command git push ${remote%%/*} :${remote#*/}
done
fi

View file

@ -3,8 +3,8 @@ setopt LOCAL_OPTIONS PIPE_FAIL
local -i stashed
stashed=$(command git stash list | wc -l) || return 1
if (( stashed )); then
if read -q "?Clear ${stashed} stashed state(s) [y/N]? "; then
command git stash clear
fi
if (( stashed )) && \
read -q "?Clear ${stashed} stashed state(s) [y/N]? "; then
print
command git stash clear
fi

View file

@ -29,8 +29,8 @@ alias gbm='git branch --move'
alias gbM='git branch --move --force'
alias gbs='git show-branch'
alias gbS='git show-branch --all'
alias gbx='git branch --delete'
alias gbX='git branch --delete --force'
alias gbx='git-branch-delete-interactive'
alias gbX='git-branch-delete-interactive --force'
# Commit (c)
alias gc='git commit --verbose'