aboutsummaryrefslogtreecommitdiffstats
path: root/src/_git-revise
blob: 7e7c1f0f1497bbf6139ac6cc7d70e27ba5ee66ef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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 "$@"