mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-16 02:40:08 +00:00
fix(git): gunwipall
now only resets once (#11758)
Closes #11750 Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
This commit is contained in:
parent
42b86327ed
commit
f5cb9a6c97
2 changed files with 8 additions and 12 deletions
|
@ -254,7 +254,7 @@ These features allow to pause a branch development and switch to another one (_"
|
||||||
| work_in_progress | Echoes a warning if the current branch is a wip |
|
| work_in_progress | Echoes a warning if the current branch is a wip |
|
||||||
| gwip | Commit wip branch |
|
| gwip | Commit wip branch |
|
||||||
| gunwip | Uncommit wip branch |
|
| gunwip | Uncommit wip branch |
|
||||||
| gunwipall | Uncommit `--wip--` commits recursively |
|
| gunwipall | Uncommit all recent `--wip--` commits |
|
||||||
|
|
||||||
### Deprecated functions
|
### Deprecated functions
|
||||||
|
|
||||||
|
|
|
@ -27,18 +27,14 @@ function work_in_progress() {
|
||||||
command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!"
|
command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Same as `gunwip` but recursive
|
# Similar to `gunwip` but recursive "Unwips" all recent `--wip--` commits not just the last one
|
||||||
# "Unwips" all recent `--wip--` commits in loop until there is no left
|
|
||||||
function gunwipall() {
|
function gunwipall() {
|
||||||
while true; do
|
local _commit=$(git log --grep='--wip--' --invert-grep --max-count=1 --format=format:%H)
|
||||||
commit_message=$(git rev-list --max-count=1 --format="%s" HEAD)
|
|
||||||
if [[ $commit_message =~ "--wip--" ]]; then
|
# Check if a commit without "--wip--" was found and it's not the same as HEAD
|
||||||
git reset "HEAD~1"
|
if [[ "$_commit" != "$(git rev-parse HEAD)" ]]; then
|
||||||
(( $? )) && return 1
|
git reset $_commit || return 1
|
||||||
else
|
fi
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if main exists and use instead of master
|
# Check if main exists and use instead of master
|
||||||
|
|
Loading…
Reference in a new issue