Zifei Tong | 5eda741 | 2010-08-22 13:22:27 +0800 | [diff] [blame] | 1 | #!zsh |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 2 | # |
Zifei Tong | 5eda741 | 2010-08-22 13:22:27 +0800 | [diff] [blame] | 3 | # Installation |
4 | # ------------ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 5 | # |
Zifei Tong | 5eda741 | 2010-08-22 13:22:27 +0800 | [diff] [blame] | 6 | # To achieve git-flow completion nirvana: |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 7 | # |
Zifei Tong | 5eda741 | 2010-08-22 13:22:27 +0800 | [diff] [blame] | 8 | # 0. Update your zsh's git-completion module to the newest verion. |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 9 | # From here. http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=blob_plain;f=Completion/Unix/Command/_git;hb=HEAD |
10 | # | ||||
Zifei Tong | 5eda741 | 2010-08-22 13:22:27 +0800 | [diff] [blame] | 11 | # 1. Install this file. Either: |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 12 | # |
Zifei Tong | 5eda741 | 2010-08-22 13:22:27 +0800 | [diff] [blame] | 13 | # a. Place it in your .zshrc: |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 14 | # |
Zifei Tong | 5eda741 | 2010-08-22 13:22:27 +0800 | [diff] [blame] | 15 | # b. Or, copy it somewhere (e.g. ~/.git-flow-completion.zsh) and put the following line in |
16 | # your .zshrc: | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 17 | # |
Zifei Tong | 5eda741 | 2010-08-22 13:22:27 +0800 | [diff] [blame] | 18 | # source ~/.git-flow-completion.zsh |
19 | # | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 20 | # c. Or, use this file as a oh-my-zsh plugin. |
Zifei Tong | 5eda741 | 2010-08-22 13:22:27 +0800 | [diff] [blame] | 21 | # |
22 | |||||
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 23 | _git-flow () |
Zifei Tong | 4b64ecc | 2010-08-21 11:20:29 +0800 | [diff] [blame] | 24 | { |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 25 | local curcontext="$curcontext" state line |
26 | typeset -A opt_args | ||||
27 | |||||
28 | _arguments -C \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 29 | ':command:->command' \ |
30 | '*::options:->options' | ||||
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 31 | |
32 | case $state in | ||||
33 | (command) | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 34 | |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 35 | local -a subcommands |
36 | subcommands=( | ||||
37 | 'init:Initialize a new git repo with support for the branching model.' | ||||
38 | 'feature:Manage your feature branches.' | ||||
39 | 'release:Manage your release branches.' | ||||
40 | 'hotfix:Manage your hotfix branches.' | ||||
41 | 'support:Manage your support branches.' | ||||
42 | 'version:Shows version information.' | ||||
43 | ) | ||||
44 | _describe -t commands 'git flow' subcommands | ||||
45 | ;; | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 46 | |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 47 | (options) |
48 | case $line[1] in | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 49 | |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 50 | (init) |
51 | _arguments \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 52 | -f'[Force setting of gitflow branches, even if already configured]' |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 53 | ;; |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 54 | |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 55 | (version) |
56 | ;; | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 57 | |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 58 | (hotfix) |
59 | __git-flow-hotfix | ||||
60 | ;; | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 61 | |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 62 | (release) |
63 | __git-flow-release | ||||
64 | ;; | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 65 | |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 66 | (feature) |
67 | __git-flow-feature | ||||
68 | ;; | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 69 | esac |
70 | ;; | ||||
71 | esac | ||||
Zifei Tong | 4b64ecc | 2010-08-21 11:20:29 +0800 | [diff] [blame] | 72 | } |
73 | |||||
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 74 | __git-flow-release () |
75 | { | ||||
76 | local curcontext="$curcontext" state line | ||||
77 | typeset -A opt_args | ||||
78 | |||||
79 | _arguments -C \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 80 | ':command:->command' \ |
81 | '*::options:->options' | ||||
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 82 | |
83 | case $state in | ||||
84 | (command) | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 85 | |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 86 | local -a subcommands |
87 | subcommands=( | ||||
Justin Hileman | 66847ba | 2011-01-18 09:49:58 -0500 | [diff] [blame] | 88 | 'start:Start a new release branch.' |
89 | 'finish:Finish a release branch.' | ||||
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 90 | 'list:List all your release branches. (Alias to `git flow release`)' |
Serhiy Oplakanets | 2790511 | 2012-07-23 12:32:50 +0300 | [diff] [blame] | 91 | 'publish:Publish release branch to remote.' |
Serhiy Oplakanets | ca710d1 | 2012-07-23 15:41:51 +0300 | [diff] [blame] | 92 | 'track:Checkout remote release branch.' |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 93 | ) |
94 | _describe -t commands 'git flow release' subcommands | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 95 | _arguments \ |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 96 | -v'[Verbose (more) output]' |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 97 | ;; |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 98 | |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 99 | (options) |
100 | case $line[1] in | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 101 | |
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 102 | (start) |
103 | _arguments \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 104 | -F'[Fetch from origin before performing finish]'\ |
105 | ':version:__git_flow_version_list' | ||||
106 | ;; | ||||
107 | |||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 108 | (finish) |
109 | _arguments \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 110 | -F'[Fetch from origin before performing finish]' \ |
111 | -s'[Sign the release tag cryptographically]'\ | ||||
112 | -u'[Use the given GPG-key for the digital signature (implies -s)]'\ | ||||
113 | -m'[Use the given tag message]'\ | ||||
114 | -p'[Push to $ORIGIN after performing finish]'\ | ||||
115 | ':version:__git_flow_version_list' | ||||
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 116 | ;; |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 117 | |
Serhiy Oplakanets | 2790511 | 2012-07-23 12:32:50 +0300 | [diff] [blame] | 118 | (publish) |
119 | _arguments \ | ||||
120 | ':version:__git_flow_version_list' | ||||
121 | ;; | ||||
122 | |||||
123 | (track) | ||||
124 | _arguments \ | ||||
125 | ':version:__git_flow_version_list' | ||||
126 | ;; | ||||
127 | |||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 128 | *) |
129 | _arguments \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 130 | -v'[Verbose (more) output]' |
131 | ;; | ||||
132 | esac | ||||
133 | ;; | ||||
134 | esac | ||||
Zifei Tong | 85b504a | 2010-08-22 10:37:55 +0800 | [diff] [blame] | 135 | } |
136 | |||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 137 | __git-flow-hotfix () |
138 | { | ||||
139 | local curcontext="$curcontext" state line | ||||
140 | typeset -A opt_args | ||||
141 | |||||
142 | _arguments -C \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 143 | ':command:->command' \ |
144 | '*::options:->options' | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 145 | |
146 | case $state in | ||||
147 | (command) | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 148 | |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 149 | local -a subcommands |
150 | subcommands=( | ||||
Justin Hileman | 66847ba | 2011-01-18 09:49:58 -0500 | [diff] [blame] | 151 | 'start:Start a new hotfix branch.' |
152 | 'finish:Finish a hotfix branch.' | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 153 | 'list:List all your hotfix branches. (Alias to `git flow hotfix`)' |
154 | ) | ||||
155 | _describe -t commands 'git flow hotfix' subcommands | ||||
156 | _arguments \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 157 | -v'[Verbose (more) output]' |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 158 | ;; |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 159 | |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 160 | (options) |
161 | case $line[1] in | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 162 | |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 163 | (start) |
164 | _arguments \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 165 | -F'[Fetch from origin before performing finish]'\ |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 166 | ':hotfix:__git_flow_version_list'\ |
167 | ':branch-name:__git_branch_names' | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 168 | ;; |
169 | |||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 170 | (finish) |
171 | _arguments \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 172 | -F'[Fetch from origin before performing finish]' \ |
173 | -s'[Sign the release tag cryptographically]'\ | ||||
174 | -u'[Use the given GPG-key for the digital signature (implies -s)]'\ | ||||
175 | -m'[Use the given tag message]'\ | ||||
176 | -p'[Push to $ORIGIN after performing finish]'\ | ||||
177 | ':hotfix:__git_flow_hotfix_list' | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 178 | ;; |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 179 | |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 180 | *) |
181 | _arguments \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 182 | -v'[Verbose (more) output]' |
183 | ;; | ||||
184 | esac | ||||
185 | ;; | ||||
186 | esac | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 187 | } |
188 | |||||
189 | __git-flow-feature () | ||||
190 | { | ||||
191 | local curcontext="$curcontext" state line | ||||
192 | typeset -A opt_args | ||||
193 | |||||
194 | _arguments -C \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 195 | ':command:->command' \ |
196 | '*::options:->options' | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 197 | |
198 | case $state in | ||||
199 | (command) | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 200 | |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 201 | local -a subcommands |
202 | subcommands=( | ||||
Justin Hileman | 66847ba | 2011-01-18 09:49:58 -0500 | [diff] [blame] | 203 | 'start:Start a new feature branch.' |
204 | 'finish:Finish a feature branch.' | ||||
MURAOKA Yusuke | c58f8c2 | 2011-01-18 06:42:31 +0900 | [diff] [blame] | 205 | 'list:List all your feature branches. (Alias to `git flow feature`)' |
Serhiy Oplakanets | ca710d1 | 2012-07-23 15:41:51 +0300 | [diff] [blame] | 206 | 'publish:Publish feature branch to remote.' |
207 | 'track:Checkout remote feature branch.' | ||||
208 | 'diff:Show all changes.' | ||||
209 | 'rebase:Rebase from integration branch.' | ||||
210 | 'checkout:Checkout local feature branch.' | ||||
211 | 'pull:Pull changes from remote.' | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 212 | ) |
MURAOKA Yusuke | c58f8c2 | 2011-01-18 06:42:31 +0900 | [diff] [blame] | 213 | _describe -t commands 'git flow feature' subcommands |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 214 | _arguments \ |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 215 | -v'[Verbose (more) output]' |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 216 | ;; |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 217 | |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 218 | (options) |
219 | case $line[1] in | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 220 | |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 221 | (start) |
222 | _arguments \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 223 | -F'[Fetch from origin before performing finish]'\ |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 224 | ':feature:__git_flow_feature_list'\ |
225 | ':branch-name:__git_branch_names' | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 226 | ;; |
227 | |||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 228 | (finish) |
229 | _arguments \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 230 | -F'[Fetch from origin before performing finish]' \ |
231 | -r'[Rebase instead of merge]'\ | ||||
232 | ':feature:__git_flow_feature_list' | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 233 | ;; |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 234 | |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 235 | (publish) |
236 | _arguments \ | ||||
237 | ':feature:__git_flow_feature_list'\ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 238 | ;; |
239 | |||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 240 | (track) |
241 | _arguments \ | ||||
242 | ':feature:__git_flow_feature_list'\ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 243 | ;; |
244 | |||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 245 | (diff) |
246 | _arguments \ | ||||
247 | ':branch:__git_branch_names'\ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 248 | ;; |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 249 | |
250 | (rebase) | ||||
251 | _arguments \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 252 | -i'[Do an interactive rebase]' \ |
253 | ':branch:__git_branch_names' | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 254 | ;; |
255 | |||||
256 | (checkout) | ||||
257 | _arguments \ | ||||
Vincent Driessen | bee8218 | 2010-08-22 21:01:01 +0800 | [diff] [blame] | 258 | ':branch:__git_flow_feature_list'\ |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 259 | ;; |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 260 | |
261 | (pull) | ||||
262 | _arguments \ | ||||
263 | ':remote:__git_remotes'\ | ||||
264 | ':branch:__git_branch_names' | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 265 | ;; |
266 | |||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 267 | *) |
268 | _arguments \ | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 269 | -v'[Verbose (more) output]' |
270 | ;; | ||||
271 | esac | ||||
272 | ;; | ||||
273 | esac | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 274 | } |
275 | |||||
276 | __git_flow_version_list () | ||||
277 | { | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 278 | local expl |
279 | declare -a versions | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 280 | |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 281 | versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}}) |
282 | __git_command_successful || return | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 283 | |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 284 | _wanted versions expl 'version' compadd $versions |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 285 | } |
286 | |||||
287 | __git_flow_feature_list () | ||||
288 | { | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 289 | local expl |
290 | declare -a features | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 291 | |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 292 | features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}}) |
293 | __git_command_successful || return | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 294 | |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 295 | _wanted features expl 'feature' compadd $features |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 296 | } |
297 | |||||
298 | __git_remotes () { | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 299 | local expl gitdir remotes |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 300 | |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 301 | gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) |
302 | __git_command_successful || return | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 303 | |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 304 | remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]}) |
305 | __git_command_successful || return | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 306 | |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 307 | # TODO: Should combine the two instead of either or. |
308 | if (( $#remotes > 0 )); then | ||||
309 | _wanted remotes expl remote compadd $* - $remotes | ||||
310 | else | ||||
311 | _wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*" | ||||
312 | fi | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 313 | } |
314 | |||||
315 | __git_flow_hotfix_list () | ||||
316 | { | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 317 | local expl |
318 | declare -a hotfixes | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 319 | |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 320 | hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}}) |
321 | __git_command_successful || return | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 322 | |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 323 | _wanted hotfixes expl 'hotfix' compadd $hotfixes |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 324 | } |
325 | |||||
326 | __git_branch_names () { | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 327 | local expl |
328 | declare -a branch_names | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 329 | |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 330 | branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/}) |
331 | __git_command_successful || return | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 332 | |
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 333 | _wanted branch-names expl branch-name compadd $* - $branch_names |
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 334 | } |
335 | |||||
336 | __git_command_successful () { | ||||
Justin Hileman | 56ff8b4 | 2011-01-18 09:58:31 -0500 | [diff] [blame] | 337 | if (( ${#pipestatus:#0} > 0 )); then |
338 | _message 'not a git repository' | ||||
339 | return 1 | ||||
340 | fi | ||||
341 | return 0 | ||||
Zifei Tong | 9414b22 | 2010-08-22 12:41:36 +0800 | [diff] [blame] | 342 | } |
343 | |||||
Dominique Lasserre | dace0bb | 2012-09-26 14:54:08 +0200 | [diff] [blame] | 344 | zstyle ':completion:*:*:git:*' user-commands flow:'provide high-level repository operations' |