Add completion for git-revise

This commit is contained in:
Hannu Hartikainen 2020-03-29 19:42:49 +03:00
parent e1523b4d68
commit bb376aee80
1 changed files with 52 additions and 0 deletions

52
src/_git-revise Normal file
View File

@ -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 "$@"