my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

526 lines
16 KiB

3 years ago
  1. _git-flow ()
  2. {
  3. local curcontext="$curcontext" state line
  4. typeset -A opt_args
  5. _arguments -C \
  6. ':command:->command' \
  7. '*::options:->options'
  8. case $state in
  9. (command)
  10. local -a subcommands
  11. subcommands=(
  12. 'init:Initialize a new git repo with support for the branching model.'
  13. 'feature:Manage your feature branches.'
  14. 'bugfix:Manage your bugfix branches.'
  15. 'config:Manage your configuration.'
  16. 'release:Manage your release branches.'
  17. 'hotfix:Manage your hotfix branches.'
  18. 'support:Manage your support branches.'
  19. 'version:Shows version information.'
  20. 'finish:Finish the branch you are currently on.'
  21. 'delete:Delete the branch you are currently on.'
  22. 'publish:Publish the branch you are currently on.'
  23. 'rebase:Rebase the branch you are currently on.'
  24. )
  25. _describe -t commands 'git flow' subcommands
  26. ;;
  27. (options)
  28. case $line[1] in
  29. (init)
  30. _arguments \
  31. -f'[Force setting of gitflow branches, even if already configured]'
  32. ;;
  33. (version)
  34. ;;
  35. (hotfix)
  36. __git-flow-hotfix
  37. ;;
  38. (release)
  39. __git-flow-release
  40. ;;
  41. (feature)
  42. __git-flow-feature
  43. ;;
  44. (bugfix)
  45. __git-flow-bugfix
  46. ;;
  47. (config)
  48. __git-flow-config
  49. ;;
  50. esac
  51. ;;
  52. esac
  53. }
  54. __git-flow-release ()
  55. {
  56. local curcontext="$curcontext" state line
  57. typeset -A opt_args
  58. _arguments -C \
  59. ':command:->command' \
  60. '*::options:->options'
  61. case $state in
  62. (command)
  63. local -a subcommands
  64. subcommands=(
  65. 'start:Start a new release branch.'
  66. 'finish:Finish a release branch.'
  67. 'list:List all your release branches. (Alias to `git flow release`)'
  68. 'publish:Publish release branch to remote.'
  69. 'track:Checkout remote release branch.'
  70. 'rebase:Rebase from integration branch.'
  71. 'delete:Delete a release branch.'
  72. )
  73. _describe -t commands 'git flow release' subcommands
  74. _arguments \
  75. -v'[Verbose (more) output]'
  76. ;;
  77. (options)
  78. case $line[1] in
  79. (start)
  80. _arguments \
  81. -F'[Fetch from origin before performing finish]'\
  82. ':version:__git_flow_version_list'
  83. ;;
  84. (finish)
  85. _arguments \
  86. -F'[Fetch from origin before performing finish]' \
  87. -s'[Sign the release tag cryptographically]'\
  88. -u'[Use the given GPG-key for the digital signature (implies -s)]'\
  89. -m'[Use the given tag message]'\
  90. -p'[Push to $ORIGIN after performing finish]'\
  91. ':version:__git_flow_version_list'
  92. ;;
  93. (delete)
  94. _arguments \
  95. -f'[Force deletion]' \
  96. -r'[Delete remote branch]' \
  97. ':version:__git_flow_version_list'
  98. ;;
  99. (publish)
  100. _arguments \
  101. ':version:__git_flow_version_list'
  102. ;;
  103. (track)
  104. _arguments \
  105. ':version:__git_flow_version_list'
  106. ;;
  107. (rebase)
  108. _arguments \
  109. -i'[Do an interactive rebase]' \
  110. ':branch:__git_branch_names'
  111. ;;
  112. *)
  113. _arguments \
  114. -v'[Verbose (more) output]'
  115. ;;
  116. esac
  117. ;;
  118. esac
  119. }
  120. __git-flow-hotfix ()
  121. {
  122. local curcontext="$curcontext" state line
  123. typeset -A opt_args
  124. _arguments -C \
  125. ':command:->command' \
  126. '*::options:->options'
  127. case $state in
  128. (command)
  129. local -a subcommands
  130. subcommands=(
  131. 'start:Start a new hotfix branch.'
  132. 'finish:Finish a hotfix branch.'
  133. 'delete:Delete a hotfix branch.'
  134. 'rebase:Rebase from integration branch.'
  135. 'list:List all your hotfix branches. (Alias to `git flow hotfix`)'
  136. 'rename:Rename a hotfix branch.'
  137. )
  138. _describe -t commands 'git flow hotfix' subcommands
  139. _arguments \
  140. -v'[Verbose (more) output]'
  141. ;;
  142. (options)
  143. case $line[1] in
  144. (start)
  145. _arguments \
  146. -F'[Fetch from origin before performing finish]'\
  147. ':hotfix:__git_flow_version_list'\
  148. ':branch-name:__git_branch_names'
  149. ;;
  150. (finish)
  151. _arguments \
  152. -F'[Fetch from origin before performing finish]' \
  153. -s'[Sign the release tag cryptographically]'\
  154. -u'[Use the given GPG-key for the digital signature (implies -s)]'\
  155. -m'[Use the given tag message]'\
  156. -p'[Push to $ORIGIN after performing finish]'\
  157. ':hotfix:__git_flow_hotfix_list'
  158. ;;
  159. (delete)
  160. _arguments \
  161. -f'[Force deletion]' \
  162. -r'[Delete remote branch]' \
  163. ':hotfix:__git_flow_hotfix_list'
  164. ;;
  165. (rebase)
  166. _arguments \
  167. -i'[Do an interactive rebase]' \
  168. ':branch:__git_branch_names'
  169. ;;
  170. *)
  171. _arguments \
  172. -v'[Verbose (more) output]'
  173. ;;
  174. esac
  175. ;;
  176. esac
  177. }
  178. __git-flow-feature ()
  179. {
  180. local curcontext="$curcontext" state line
  181. typeset -A opt_args
  182. _arguments -C \
  183. ':command:->command' \
  184. '*::options:->options'
  185. case $state in
  186. (command)
  187. local -a subcommands
  188. subcommands=(
  189. 'start:Start a new feature branch.'
  190. 'finish:Finish a feature branch.'
  191. 'delete:Delete a feature branch.'
  192. 'list:List all your feature branches. (Alias to `git flow feature`)'
  193. 'publish:Publish feature branch to remote.'
  194. 'track:Checkout remote feature branch.'
  195. 'diff:Show all changes.'
  196. 'rebase:Rebase from integration branch.'
  197. 'checkout:Checkout local feature branch.'
  198. 'pull:Pull changes from remote.'
  199. 'rename:Rename a feature branch.'
  200. )
  201. _describe -t commands 'git flow feature' subcommands
  202. _arguments \
  203. -v'[Verbose (more) output]'
  204. ;;
  205. (options)
  206. case $line[1] in
  207. (start)
  208. _arguments \
  209. -F'[Fetch from origin before performing finish]'\
  210. ':feature:__git_flow_feature_list'\
  211. ':branch-name:__git_branch_names'
  212. ;;
  213. (finish)
  214. _arguments \
  215. -F'[Fetch from origin before performing finish]' \
  216. -r'[Rebase instead of merge]'\
  217. ':feature:__git_flow_feature_list'
  218. ;;
  219. (delete)
  220. _arguments \
  221. -f'[Force deletion]' \
  222. -r'[Delete remote branch]' \
  223. ':feature:__git_flow_feature_list'
  224. ;;
  225. (publish)
  226. _arguments \
  227. ':feature:__git_flow_feature_list'\
  228. ;;
  229. (track)
  230. _arguments \
  231. ':feature:__git_flow_feature_list'\
  232. ;;
  233. (diff)
  234. _arguments \
  235. ':branch:__git_branch_names'\
  236. ;;
  237. (rebase)
  238. _arguments \
  239. -i'[Do an interactive rebase]' \
  240. ':branch:__git_branch_names'
  241. ;;
  242. (checkout)
  243. _arguments \
  244. ':branch:__git_flow_feature_list'\
  245. ;;
  246. (pull)
  247. _arguments \
  248. ':remote:__git_remotes'\
  249. ':branch:__git_branch_names'
  250. ;;
  251. *)
  252. _arguments \
  253. -v'[Verbose (more) output]'
  254. ;;
  255. esac
  256. ;;
  257. esac
  258. }
  259. __git-flow-bugfix ()
  260. {
  261. local curcontext="$curcontext" state line
  262. typeset -A opt_args
  263. _arguments -C \
  264. ':command:->command' \
  265. '*::options:->options'
  266. case $state in
  267. (command)
  268. local -a subcommands
  269. subcommands=(
  270. 'start:Start a new bugfix branch.'
  271. 'finish:Finish a bugfix branch.'
  272. 'delete:Delete a bugfix branch.'
  273. 'list:List all your bugfix branches. (Alias to `git flow bugfix`)'
  274. 'publish:Publish bugfix branch to remote.'
  275. 'track:Checkout remote bugfix branch.'
  276. 'diff:Show all changes.'
  277. 'rebase:Rebase from integration branch.'
  278. 'checkout:Checkout local bugfix branch.'
  279. 'pull:Pull changes from remote.'
  280. 'rename:Rename a bugfix branch.'
  281. )
  282. _describe -t commands 'git flow bugfix' subcommands
  283. _arguments \
  284. -v'[Verbose (more) output]'
  285. ;;
  286. (options)
  287. case $line[1] in
  288. (start)
  289. _arguments \
  290. -F'[Fetch from origin before performing finish]'\
  291. ':bugfix:__git_flow_bugfix_list'\
  292. ':branch-name:__git_branch_names'
  293. ;;
  294. (finish)
  295. _arguments \
  296. -F'[Fetch from origin before performing finish]' \
  297. -r'[Rebase instead of merge]'\
  298. ':bugfix:__git_flow_bugfix_list'
  299. ;;
  300. (delete)
  301. _arguments \
  302. -f'[Force deletion]' \
  303. -r'[Delete remote branch]' \
  304. ':bugfix:__git_flow_bugfix_list'
  305. ;;
  306. (publish)
  307. _arguments \
  308. ':bugfix:__git_flow_bugfix_list'\
  309. ;;
  310. (track)
  311. _arguments \
  312. ':bugfix:__git_flow_bugfix_list'\
  313. ;;
  314. (diff)
  315. _arguments \
  316. ':branch:__git_branch_names'\
  317. ;;
  318. (rebase)
  319. _arguments \
  320. -i'[Do an interactive rebase]' \
  321. ':branch:__git_branch_names'
  322. ;;
  323. (checkout)
  324. _arguments \
  325. ':branch:__git_flow_bugfix_list'\
  326. ;;
  327. (pull)
  328. _arguments \
  329. ':remote:__git_remotes'\
  330. ':branch:__git_branch_names'
  331. ;;
  332. *)
  333. _arguments \
  334. -v'[Verbose (more) output]'
  335. ;;
  336. esac
  337. ;;
  338. esac
  339. }
  340. __git-flow-config ()
  341. {
  342. local curcontext="$curcontext" state line
  343. typeset -A opt_args
  344. _arguments -C \
  345. ':command:->command' \
  346. '*::options:->options'
  347. case $state in
  348. (command)
  349. local -a subcommands
  350. subcommands=(
  351. 'list:List the configuration. (Alias to `git flow config`)'
  352. 'set:Set the configuration option'
  353. )
  354. _describe -t commands 'git flow config' subcommands
  355. ;;
  356. (options)
  357. case $line[1] in
  358. (set)
  359. _arguments \
  360. --local'[Use repository config file]' \
  361. --global'[Use global config file]'\
  362. --system'[Use system config file]'\
  363. --file'[Use given config file]'\
  364. ':option:(master develop feature hotfix release support versiontagprefix)'
  365. ;;
  366. *)
  367. _arguments \
  368. --local'[Use repository config file]' \
  369. --global'[Use global config file]'\
  370. --system'[Use system config file]'\
  371. --file'[Use given config file]'
  372. ;;
  373. esac
  374. ;;
  375. esac
  376. }
  377. __git_flow_version_list ()
  378. {
  379. local expl
  380. declare -a versions
  381. versions=(${${(f)"$(_call_program versions git flow release list 2> /dev/null | tr -d ' |*')"}})
  382. __git_command_successful || return
  383. _wanted versions expl 'version' compadd $versions
  384. }
  385. __git_flow_feature_list ()
  386. {
  387. local expl
  388. declare -a features
  389. features=(${${(f)"$(_call_program features git flow feature list 2> /dev/null | tr -d ' |*')"}})
  390. __git_command_successful || return
  391. _wanted features expl 'feature' compadd $features
  392. }
  393. __git_flow_bugfix_list ()
  394. {
  395. local expl
  396. declare -a bugfixes
  397. bugfixes=(${${(f)"$(_call_program bugfixes git flow bugfix list 2> /dev/null | tr -d ' |*')"}})
  398. __git_command_successful || return
  399. _wanted bugfixes expl 'bugfix' compadd $bugfixes
  400. }
  401. __git_remotes () {
  402. local expl gitdir remotes
  403. gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null)
  404. __git_command_successful || return
  405. remotes=(${${(f)"$(_call_program remotes git config --get-regexp '"^remote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]})
  406. __git_command_successful || return
  407. # TODO: Should combine the two instead of either or.
  408. if (( $#remotes > 0 )); then
  409. _wanted remotes expl remote compadd $* - $remotes
  410. else
  411. _wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gitdir/remotes/*"
  412. fi
  413. }
  414. __git_flow_hotfix_list ()
  415. {
  416. local expl
  417. declare -a hotfixes
  418. hotfixes=(${${(f)"$(_call_program hotfixes git flow hotfix list 2> /dev/null | tr -d ' |*')"}})
  419. __git_command_successful || return
  420. _wanted hotfixes expl 'hotfix' compadd $hotfixes
  421. }
  422. __git_branch_names () {
  423. local expl
  424. declare -a branch_names
  425. branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/})
  426. __git_command_successful || return
  427. _wanted branch-names expl branch-name compadd $* - $branch_names
  428. }
  429. __git_command_successful () {
  430. if (( ${#pipestatus:#0} > 0 )); then
  431. _message 'not a git repository'
  432. return 1
  433. fi
  434. return 0
  435. }
  436. zstyle ':completion:*:*:git:*' user-commands flow:'provide high-level repository operations'