Skip to content

Commit

Permalink
chore: implement alias for gunwip (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
luismayta committed Feb 2, 2024
1 parent a548156 commit 79fa56e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/base.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions pkg/alias.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 79fa56e

Please sign in to comment.