summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorIhor <kopach@users.noreply.github.com>2023-06-05 10:38:54 +0200
committerGitHub <noreply@github.com>2023-06-05 10:38:54 +0200
commit115cee17015e4b5665e16dc4fd15c53e06a22f9a (patch)
tree9070dca2c36810fc057ebe7e549f4f2b33e1809c /plugins
parentd1c64bfda30ad56bac09f11c920b93b94dab7f9f (diff)
downloadzsh-115cee17015e4b5665e16dc4fd15c53e06a22f9a.tar.gz
zsh-115cee17015e4b5665e16dc4fd15c53e06a22f9a.tar.bz2
zsh-115cee17015e4b5665e16dc4fd15c53e06a22f9a.zip
feat(git): add `gunwipall` function (#11725)
Co-authored-by: Carlo Sala <carlosalag@protonmail.com>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/git/README.md1
-rw-r--r--plugins/git/git.plugin.zsh14
2 files changed, 15 insertions, 0 deletions
diff --git a/plugins/git/README.md b/plugins/git/README.md
index 2742aa539..bf4b19f39 100644
--- a/plugins/git/README.md
+++ b/plugins/git/README.md
@@ -254,6 +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 |
| gwip | Commit wip branch |
| gunwip | Uncommit wip branch |
+| gunwipall | Uncommit `--wip--` commits recursively |
### Deprecated functions
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index 4be865f6a..192124301 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -27,6 +27,20 @@ function work_in_progress() {
command git -c log.showSignature=false log -n 1 2>/dev/null | grep -q -- "--wip--" && echo "WIP!!"
}
+# Same as `gunwip` but recursive
+# "Unwips" all recent `--wip--` commits in loop until there is no left
+function gunwipall() {
+ while true; do
+ commit_message=$(git rev-list --max-count=1 --format="%s" HEAD)
+ if [[ $commit_message =~ "--wip--" ]]; then
+ git reset "HEAD~1"
+ (( $? )) && return 1
+ else
+ break
+ fi
+ done
+}
+
# Check if main exists and use instead of master
function git_main_branch() {
command git rev-parse --git-dir &>/dev/null || return