forked from nix-community/nix-zsh-completions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_nixpkgs-review
66 lines (55 loc) · 1.8 KB
/
_nixpkgs-review
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
#compdef nixpkgs-review
#autoload
local context state state_descr line
typeset -A opt_args
_nix-common-options
local -a common_args=(
'--build-args=[arguments passed to nix when building]:build args:'
'--no-shell[Only evaluate and build without executing nix-shell]'
'(-h --help)'{--help,-h}'[show help]'
'--token[github token]:github token:'
)
local -a common_cmd_args=(
'*'{-p,--package}'[build package]:package: _nix_attr_paths "import ./. {}"'
'*--package-regex[only build packages matching regex]:regex:'
)
local -a pr_args=(
':pr number to review:'
'(-c --checkout)'{-c,--checkout}'[merge before building or use exact commit]:merge or commit:(merge commit)'
"--eval[use ofborg's eval result]::(ofborg local)"
"--post-result[Post the nixpkgs-review results as a PR comment]"
)
local -a wip_args=(
'(-b --branch)'{-b,--branch}'[Branch to compare against with]:branch:__git_ref_specs'
'(-s --staged)'{-s,--staged}'[Whether to build staged changes]'
'(-r --remote)'{-r,--remote}'[Name of the nixpkgs repo to review]:remote:'
)
if ! which __git_ref_specs > /dev/null; then
_git &> /dev/null
fi
local -a rev_args=(
':commit/tag/ref/branch to review:__git_ref_specs'
'(-b --branch)'{-b,--branch}'[branch to compare against]:branch:__git_ref_specs'
)
_arguments \
'*: :->subcmds' && return 0
local command=${line[1]}
local -a args=()
case $command in
pr)
args=($pr_args $common_cmd_args)
;;
rev)
args=($rev_args $common_cmd_args)
;;
wip)
args=($wip_args $common_cmd_args)
;;
post-result|merge|approve)
args=($common_cmd_args)
;;
esac
_arguments \
$common_args \
':review PR, a local git rev or uncommited changes:(pr rev wip post-result merge approve)' \
$args && return 0