diff --git a/internal/base.zsh b/internal/base.zsh index 64d4b3c..e6220ca 100644 --- a/internal/base.zsh +++ b/internal/base.zsh @@ -43,3 +43,14 @@ function git::internal::provision::hooks::sync { fi rsync -avP "${ZSH_GIT_HOOKS_PATH}/" "${GIT_PROVISION_HOOKS_PATH}/" } + +# Similar to `gunwip` but recursive "Unwips" all recent `--wip--` commits not just the last one +function git::internal::gunwipall { + local _commit + _commit="$(git log --grep='--wip--' --invert-grep --max-count=1 --format=format:%H)" + + # Check if a commit without "--wip--" was found and it's not the same as HEAD + if [[ "${_commit}" != "$(git rev-parse HEAD)" ]]; then + git reset "${_commit}" || return 1 + fi +} \ No newline at end of file diff --git a/pkg/alias.zsh b/pkg/alias.zsh index 9b06473..77a8ee9 100644 --- a/pkg/alias.zsh +++ b/pkg/alias.zsh @@ -19,6 +19,9 @@ alias gwip='git add -A; git rm $(git ls-files --deleted) 2> /dev/null; git commi alias gunwip='git rev-list --max-count=1 --format="%s" HEAD | grep -q "\--wip--" && git reset HEAD~1' +function gunwipall { + git::internal::gunwipall +} # Git Flow