-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_stak
More file actions
111 lines (101 loc) · 3.31 KB
/
_stak
File metadata and controls
111 lines (101 loc) · 3.31 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#compdef stak
# Zsh completion for stak - stacked changes for git
_stak_commands() {
local commands=(
'new:Create a new branch on top of current'
'insert:Insert branch at any position'
'split:Split current branch commits'
'up:Move up the stack'
'down:Move down the stack'
'goto:Jump to any branch in the stack'
'status:Show the current stack'
'st:Show the current stack (alias)'
'sync:Rebase entire stack'
'continue:Continue after resolving conflicts'
'abort:Abort current rebase'
'push:Push branches to remote'
'drop:Remove current branch from stack'
'fold:Fold branch into parent or child'
'land:Clean up after PR is merged'
'log:Show commits in the stack'
'ls:List all stacks'
'use:Switch to stack (creates if needed)'
'rm-stack:Delete a stack'
'setup-interactive:Install fzf for interactive mode'
'help:Show help'
)
_describe 'command' commands
}
_stak_names() {
local stacks_dir=".git/stacks"
if [[ -d "$stacks_dir" ]]; then
local stacks=(${(f)"$(ls $stacks_dir 2>/dev/null)"})
_describe 'stack' stacks
fi
}
_stak_branches() {
local current_stack_file=".git/stack-current"
local stacks_dir=".git/stacks"
local stack_name="default"
[[ -f "$current_stack_file" ]] && stack_name=$(cat "$current_stack_file")
local stack_file="$stacks_dir/$stack_name"
if [[ -f "$stack_file" ]]; then
local branches=(${(f)"$(cat $stack_file)"})
_describe 'branch' branches
fi
}
_stak() {
local curcontext="$curcontext" state line
_arguments -C \
'1: :_stak_commands' \
'*::arg:->args'
case $state in
args)
case $line[1] in
new)
_message 'branch name'
;;
goto)
_alternative \
'branches:branch:_stak_branches' \
'numbers:position:(1 2 3 4 5 6 7 8 9 10)'
;;
fold)
_arguments \
'--down[Fold into child branch]' \
'-d[Fold into child branch]'
;;
push)
_arguments \
'--all[Push all branches]' \
'-a[Push all branches]'
;;
log)
_alternative \
'options:option:(--all -a)' \
'branches:branch:_stak_branches'
;;
land)
_arguments \
'--force[Force land for squash merges]' \
'-f[Force land for squash merges]'
;;
use)
_stak_names
;;
rm-stack)
_stak_names
;;
insert)
_arguments \
'1:branch name:' \
'--after[Insert after branch]:branch:_stak_branches'
;;
split)
_message 'new branch name'
;;
esac
;;
esac
}
_stak "$@"