3162de563f0db29e7b91faf6b05281518a431d13
- Author
- Marc Cornellà <marc.cornella@live.com>
- Committer
- Marc Cornellà <marc.cornella@live.com>
- Date
Message
Diff
This diff is truncated to protect this page.
1diff --git a/plugins/github/_hub b/plugins/github/_hub
2new file mode 100644
3index 0000000000000000000000000000000000000000..3a64938784d3b41d65973eb5953ead8896377c5e
4--- /dev/null
5+++ b/plugins/github/_hub
6@@ -0,0 +1,163 @@
7+#compdef hub
8+
9+# Zsh will source this file when attempting to autoload the "_hub" function,
10+# typically on the first attempt to complete the hub command. We define two new
11+# setup helper routines (one for the zsh-distributed version, one for the
12+# git-distributed, bash-based version). Then we redefine the "_hub" function to
13+# call "_git" after some other interception.
14+#
15+# This is pretty fragile, if you think about it. Any number of implementation
16+# changes in the "_git" scripts could cause problems down the road. It would be
17+# better if the stock git completions were just a bit more permissive about how
18+# it allowed third-party commands to be added.
19+
20+(( $+functions[__hub_setup_zsh_fns] )) ||
21+__hub_setup_zsh_fns () {
22+ (( $+functions[_git-alias] )) ||
23+ _git-alias () {
24+ _arguments \
25+ '-s[output shell script suitable for eval]' \
26+ '1::shell:(zsh bash csh)'
27+ }
28+
29+ (( $+functions[_git-browse] )) ||
30+ _git-browse () {
31+ _arguments \
32+ '-u[output the URL]' \
33+ '2::subpage:(wiki commits issues)'
34+ }
35+
36+ (( $+functions[_git-compare] )) ||
37+ _git-compare () {
38+ _arguments \
39+ '-u[output the URL]' \
40+ ':[start...]end range:'
41+ }
42+
43+ (( $+functions[_git-create] )) ||
44+ _git-create () {
45+ _arguments \
46+ '::name (REPOSITORY or ORGANIZATION/REPOSITORY):' \
47+ '-p[make repository private]' \
48+ '-d[description]:description' \
49+ '-h[home page]:repository home page URL:_urls'
50+ }
51+
52+ (( $+functions[_git-fork] )) ||
53+ _git-fork () {
54+ _arguments \
55+ '--no-remote[do not add a remote for the new fork]'
56+ }
57+
58+ (( $+functions[_git-pull-request] )) ||
59+ _git-pull-request () {
60+ _arguments \
61+ '-f[force (skip check for local commits)]' \
62+ '-b[base]:base ("branch", "owner\:branch", "owner/repo\:branch"):' \
63+ '-h[head]:head ("branch", "owner\:branch", "owner/repo\:branch"):' \
64+ - set1 \
65+ '-m[message]' \
66+ '-F[file]' \
67+ '-a[user]' \
68+ '-M[milestone]' \
69+ '-l[labels]' \
70+ - set2 \
71+ '-i[issue]:issue number:' \
72+ - set3 \
73+ '::issue-url:_urls'
74+ }
75+
76+ # stash the "real" command for later
77+ functions[_hub_orig_git_commands]=$functions[_git_commands]
78+
79+ # Replace it with our own wrapper.
80+ declare -f _git_commands >& /dev/null && unfunction _git_commands
81+ _git_commands () {
82+ local ret=1
83+ # call the original routine
84+ _call_function ret _hub_orig_git_commands
85+
86+ # Effectively "append" our hub commands to the behavior of the original
87+ # _git_commands function. Using this wrapper function approach ensures
88+ # that we only offer the user the hub subcommands when the user is
89+ # actually trying to complete subcommands.
90+ hub_commands=(
91+ alias:'show shell instructions for wrapping git'
92+ pull-request:'open a pull request on GitHub'
93+ fork:'fork origin repo on GitHub'
94+ create:'create new repo on GitHub for the current project'
95+ browse:'browse the project on GitHub'
96+ compare:'open GitHub compare view'
97+ ci-status:'lookup commit in GitHub Status API'
98+ )
99+ _describe -t hub-commands 'hub command' hub_commands && ret=0
100+
101+ return ret
102+ }
103+}
104+
105+(( $+functions[__hub_setup_bash_fns] )) ||