From bb376aee802b722fef7dbe5a94dcd00f873fc76c Mon Sep 17 00:00:00 2001 From: Hannu Hartikainen Date: Sun, 29 Mar 2020 19:42:49 +0300 Subject: [PATCH] Add completion for git-revise --- src/_git-revise | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/_git-revise diff --git a/src/_git-revise b/src/_git-revise new file mode 100644 index 0000000..7e7c1f0 --- /dev/null +++ b/src/_git-revise @@ -0,0 +1,52 @@ +#compdef git-revise +#description update, split and rearrange commits +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# Completion script for git-revise 0.5.1 +# (https://github.com/mystor/git-revise/). +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Hannu Hartikainen (https://github.com/dancek) +# +# ------------------------------------------------------------------------------ + +__git-revise_commits() { + local -a commits + commits=(${(f)"$(git log -20 --pretty=format:'%h:%d %s' | sed 's/: /:/')"}) + _describe -V 'commit' commits +} + +__git-revise_branches() { + local -a branches + branches=(${(f)"$(git for-each-ref --format='%(refname:short)' refs/heads/)"}) + _describe 'branch' branches +} + +_git-revise() { + local curcontext="$curcontext" ret=1 + + _arguments -s \ + '(- :)'{-h,--help}'[show help message and exit]' \ + '--ref=[reference to update]: :__git-revise_branches' \ + '--reauthor[reset the author of the targeted commit]' \ + '(- :)--version[show version number and exit]' \ + '(--edit -e)'{--edit,-e}'[edit commit message of targeted commit(s)]' \ + '(--no-autosquash)--autosquash[automatically apply fixup! and squash! commits to their targets]' \ + '(--autosquash)--no-autosquash[force disable revise.autoSquash behaviour]' \ + '(--all -a)--no-index[ignore the index while rewriting history]' \ + '(--no-index --all -a)'{--all,-a}'[stage all tracked files before running]' \ + '(--interactive -i --message -m --cut -c)'{--interactive,-i}'[interactively edit commit stack]' \ + '(--interactive -i --message -m --cut -c)'{--message,-m}'[specify commit message on command line]:MESSAGE:()' \ + '(--interactive -i --message -m --cut -c)'{--cut,-c}'[interactively cut a commit into two smaller commits]' \ + '1: :__git-revise_commits' && ret=0 + + return $ret +} + +_git-revise "$@" +