git-buildpackage.zsh-completion 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. #compdef gbp
  2. #description build Debian packages from a Git repository
  3. __gbp_common_options() {
  4. local prefix="$1"
  5. # these can't be prefixed
  6. _arguments '--help[Show help]' \
  7. '--version[Show version information]'
  8. _arguments "--${prefix}verbose[Verbose execution]" \
  9. "--${prefix}color=-[Use colored output]:color:(on auto off)"
  10. }
  11. __gbp_branch_options() {
  12. local prefix="$1"
  13. _arguments \
  14. "--${prefix}debian-branch=-[The branch the Debian package is being developed on]" \
  15. "--${prefix}upstream-branch=-[The branch the upstream sources are put onto]" \
  16. "--${prefix}pristine-tar[Track pristine tar branch]"
  17. }
  18. __gbp_tag_format_options() {
  19. local prefix="$1"
  20. _arguments \
  21. "--${prefix}debian-tag=-[format string for debian tags]" \
  22. "--${prefix}upstream-tag=-[format string for upstream tags]"
  23. }
  24. __gbp_tag_sign_options() {
  25. local prefix="$1"
  26. _arguments \
  27. "(--${prefix}sign-tags --${prefix}no-sign-tags)--${prefix}sign-tags[GPG sign all generated tags]" \
  28. "(--${prefix}sign-tags --${prefix}no-sign-tags)--${prefix}no-sign-tags[Do not GPG sign generated tags]" \
  29. "--${prefix}keyid=-[GPG keyid to sign tags with]:GPG key:"
  30. }
  31. _gbp() {
  32. local curcontext="$curcontext" state line
  33. typeset -A opt_args
  34. _arguments -C \
  35. ':command:->command' \
  36. '*::options:->options' \
  37. case $state in
  38. (command)
  39. #breaks if defined outside the func
  40. local -a subcommands
  41. subcommands=(
  42. 'buildpackage:Build a Debian package'
  43. 'clone:Clone a Git repository from a remote and set up the necessary branch tracking.'
  44. 'create-remote-repo:Create a remote Git repository'
  45. 'dch:Generate the debian/changelog from Git commit history'
  46. 'import-dsc:Import a single Debian source package'
  47. 'import-dscs:Import multiple Debian source packages'
  48. 'import-orig:Import a new upstream tarball'
  49. 'pq:Manage debian/patches using Git rebase'
  50. 'pull:Update a Git repository from a remote'
  51. )
  52. _describe -t commands gbp subcommands
  53. ;;
  54. (options)
  55. local funcname
  56. funcname=_gbp-$line[1]
  57. if type $funcname | grep -q "shell function" ; then
  58. $funcname
  59. fi
  60. ;;
  61. esac
  62. }
  63. _gbp-buildpackage() {
  64. __gbp_common_options git-
  65. __gbp_branch_options git-
  66. __gbp_tag_format_options git-
  67. __gbp_tag_sign_options git-
  68. _arguments \
  69. '--git-ignore-new[build with uncommited changes in the source tree]' \
  70. '--git-no-ignore-new[negates --git-ignore-new]' \
  71. '--git-tag[create a tag after a successful build]' \
  72. '--git-tag-only[do not build, only tag and run the posttag hook]' \
  73. '--git-retag[do not fail if the tag already exists]' \
  74. '--git-force-create[force creation of orig.tar.gz]' \
  75. '--git-no-create-orig[do not create orig.tar.gz]' \
  76. '--git-tarball-dir=-[location to look for external tarballs]:tarball directory:_files -/' \
  77. '--git-compression=-[compression type]:compression:(auto gzip bzip2 lzma xz)' \
  78. '--git-compression-level=-[set compression level]:level:(1 2 3 4 5 6 7 8 9)' \
  79. '--git-ignore-branch[build although debian-branch != current branch]' \
  80. '--git-no-ignore-branch[negates --git-ignore-branch]' \
  81. '--git-builder=-[command to build the Debian package]:command:' \
  82. '--git-cleaner=-[command to clean the working copy]:command:' \
  83. '--git-prebuild=-[command to run before a build]:command:' \
  84. '--git-postbuild=-[hook run after a successful build]:command:' \
  85. '--git-posttag=-[hook run after a successful tag operation]:command:' \
  86. '--git-pbuilder[invoke git-pbuilder for building]' \
  87. '--git-no-pbuilder[negates --git-pbuilder]' \
  88. '--git-dist=-[build for this distribution when using git-pbuilder]:distribution:' \
  89. '--git-arch=-[build for this architecture when using git-pbuilder]:architecture:' \
  90. '--git-export-dir=-[before building the package export the source into this directory]:directory:_files -/' \
  91. '--git-export=-[export treeish object instead of HEAD]:treeish:' \
  92. '--git-dont-purge[retain exported package build directory]' \
  93. '--git-overlay[extract orig tarball when using export-dir option]' \
  94. '--git-no-overlay[negates --git-overlay]' \
  95. '--git-notify=-[Send a desktop notification after build]:notify:(on auto off)' \
  96. '*:Other options:_dpkg-buildpackage'
  97. }
  98. _gbp-clone() {
  99. __gbp_common_options
  100. __gbp_branch_options
  101. _arguments \
  102. '--all[Track all branches, not only debian and upstream]'
  103. }
  104. _gbp-create-remote-repo() {
  105. __gbp_common_options
  106. _arguments \
  107. '--remote-url-pattern=-[Where to create remote repository]' \
  108. '--remote-name=-[What name git will use when refering to that repository]' \
  109. '--template-dir=-[Template dir to pass to git init]' \
  110. '--remote-config=-[Name of config file section to specify params]' \
  111. '(--track --no-track)--track[Set up branch tracking]' \
  112. '(--track --no-track)--no-track[Do not set up branch tracking]'
  113. }
  114. _gbp-dch () {
  115. __gbp_common_options
  116. __gbp_branch_options
  117. __gbp_tag_format_options
  118. _arguments \
  119. '--git-ignore-branch[build although debian-branch != current branch]' \
  120. '--since=-[Start point for reading commits]:commitish:' \
  121. '--auto[Guess the last commit documented in the changelog]' \
  122. '(--meta --no-meta)--meta[Parse meta tags]' \
  123. '(--meta --no-meta)--no-meta[Do not parse meta tags]' \
  124. '--meta-closes=-[What meta tags to look for to generate bug-closing changelog entries]' \
  125. '--meta-closes-bugnum=-[What bug number format to look for to generate bug-closing changelog entries]' \
  126. '(--full --no-full)--full[Include the full commit message]' \
  127. '(--full --no-full)--no-full[Do not include the full commit message]' \
  128. '(--snapshot -S)'{-S,--snapshot}'[Create a snapshot release entry]' \
  129. '--snapshot-number=-[Python expression that gets eval()ed to the new snapshot number]' \
  130. '(--release -R)'{-R,--release}'[Remove any snapshot release banners]' \
  131. '(--new-version -N)'{-R,--release}'=[Specify changelog version]' \
  132. '--team[Create a team upload entry]' \
  133. '--bpo[Increment the release number for a backports upload]' \
  134. '--nmu[Increment the release number for a NMU upload]' \
  135. '--qa[Increment the release number for a QA upload]' \
  136. '--distribution=-[Set the distribution field]' \
  137. '--force-distribution[Force distribution]' \
  138. '--urgency=-[Set the upload urgency]' \
  139. '--git-log=-[Options passed to git log]' \
  140. '--id-length=-[Number of commit id digits to include]' \
  141. '--ignore-regex=-[Ignore matching commit lines]' \
  142. '--git-author[Use git name configuration for changelog signature]' \
  143. '(--multimaint-merge --no-multimaint-merge)--multimaint-merge[Merge commits by maintainer]' \
  144. '(--multimaint-merge --no-multimaint-merge)--multimaint-merge[Do not merge commits by maintainer]' \
  145. '--spawn-editor=[Spawn an editor]:when:(always snapshot release)' \
  146. '--commit-msg=[Commit message format string]' \
  147. '--commit[Commit the generated changelog]' \
  148. '*:Paths:_files -/'
  149. }
  150. _gbp-import-dsc() {
  151. __gbp_common_options
  152. __gbp_branch_options
  153. __gbp_tag_format_options
  154. __gbp_tag_sign_options
  155. _arguments \
  156. '--filter=-[Filter out files]' \
  157. '--download=-[Download the source package]' \
  158. '--allow-unauthenticated[Skip signature verification on downloads]' \
  159. '--allow-same-version[Import a package with the same debian version]' \
  160. '--author-is-committer[Use the author identity as committer identity]' \
  161. '--author-date-is-committer-date[Use author date as commit date]' \
  162. '*:package:_files -g "*.dsc"'
  163. # TODO: complete source package names
  164. # TODO: pass only one tarball/source package name
  165. }
  166. _gbp-import-dscs() {
  167. # same options
  168. _gbp-import_dsc
  169. _arguments \
  170. '--debsnap[Fetch snapshots from snapshots.debian.org]' \
  171. '--ignore-repo-config[Ignore options in gbp.conf]'
  172. # TODO: multiple dscs or one source package name + debsnap
  173. }
  174. _gbp-import-orig() {
  175. __gbp_common_options
  176. __gbp_branch_options
  177. __gbp_tag_format_options
  178. __gbp_tag_sign_options
  179. _arguments \
  180. '(--upstream-version -u)'{--upstream-version,-u}'=[The upstream version number]' \
  181. '--merge[Merge the upstream branch into the debian branch]' \
  182. '--upstream-vcs-tag=-[Add a tag as an additional parent to the upstream tarball commit]' \
  183. '--import-msg=-[Commit message format string]' \
  184. '--filter=-[Filter out files]' \
  185. '--filter-pristine-tar[When filtering also filter out of pristine-tar tarballs]' \
  186. '(--symlink-orig --no-symlink-orig)--symlink-orig=[Create a symlink with a debian-compliant name]' \
  187. '(--symlink-orig --no-symlink-orig)--no-symlink-orig=[Do not create a symlink with a debian-compliant name]' \
  188. '--postimport=-[Run a command after import]' \
  189. '--uscan[Use uscan to fetch the new upstream version]' \
  190. '*:file:_files'
  191. # TODO: pass only one tarball
  192. # TODO: Do not complete files when uscan option is enabled
  193. }
  194. _gbp-pq() {
  195. __gbp_common_options
  196. _arguments \
  197. '(--patch-numbers --no-patch-numbers)--patch-numbers[Add numbers to patch files]' \
  198. '(--patch-numbers --no-patch-numbers)--no-patch-numbers[Do not add numbers to patch files]' \
  199. '--topic=-[Topic to use when importing a single patch]' \
  200. '--time-machine=-[Go back N commits trying to apply patch queue]'
  201. local -a pqcommands
  202. pqcommands=(
  203. 'import:Create a patch queue branch'
  204. 'export:Export the patches on the patch-queue branch'
  205. 'rebase:Rebase the patch-queue branch against the current branch'
  206. 'drop:Drop the patch queue'
  207. 'apply:Add a single patch to the patch-queue'
  208. 'switch:Switch to the patch-queue branch if on the base branch and viceversa'
  209. )
  210. # TODO: only display these commands once
  211. _describe -t pqcommands gbp-pq pqcommands
  212. }
  213. _gbp-pull() {
  214. __gbp_common_options
  215. __gbp_branch_options
  216. _arguments \
  217. '--force[Update even non fast-forward]' \
  218. '--redo-pq[Rebuild the patch queue]' \
  219. '--ignore-branch[Dont care if on a detached state]' \
  220. '--depth=-[Depth for deepening shallow clones]'
  221. }
  222. _gbp "$@"
  223. __gbp_common_options() {
  224. local prefix="$1"
  225. # these can't be prefixed
  226. _arguments '--help[Show help]' \
  227. '--version[Show version information]'
  228. _arguments "--${prefix}verbose[Verbose execution]" \
  229. "--${prefix}color=-[Use colored output]:color:(on auto off)"
  230. }
  231. __gbp_branch_options() {
  232. local prefix="$1"
  233. _arguments \
  234. "--${prefix}debian-branch=-[The branch the Debian package is being developed on]" \
  235. "--${prefix}upstream-branch=-[The branch the upstream sources are put onto]" \
  236. "--${prefix}pristine-tar[Track pristine tar branch]"
  237. }
  238. __gbp_tag_format_options() {
  239. local prefix="$1"
  240. _arguments \
  241. "--${prefix}debian-tag=-[format string for debian tags]" \
  242. "--${prefix}upstream-tag=-[format string for upstream tags]"
  243. }
  244. __gbp_tag_sign_options() {
  245. local prefix="$1"
  246. _arguments \
  247. "(--${prefix}sign-tags --${prefix}no-sign-tags)--${prefix}sign-tags[GPG sign all generated tags]" \
  248. "(--${prefix}sign-tags --${prefix}no-sign-tags)--${prefix}no-sign-tags[Do not GPG sign generated tags]" \
  249. "--${prefix}keyid=-[GPG keyid to sign tags with]:GPG key:"
  250. }
  251. _gbp() {
  252. local curcontext="$curcontext" state line
  253. typeset -A opt_args
  254. _arguments -C \
  255. ':command:->command' \
  256. '*::options:->options' \
  257. case $state in
  258. (command)
  259. #breaks if defined outside the func
  260. local -a subcommands
  261. subcommands=(
  262. 'buildpackage:Build a Debian package'
  263. 'clone:Clone a Git repository from a remote and set up the necessary branch tracking.'
  264. 'create-remote-repo:Create a remote Git repository'
  265. 'dch:Generate the debian/changelog from Git commit history'
  266. 'import-dsc:Import a single Debian source package'
  267. 'import-dscs:Import multiple Debian source packages'
  268. 'import-orig:Import a new upstream tarball'
  269. 'pq:Manage debian/patches using Git rebase'
  270. 'pull:Update a Git repository from a remote'
  271. )
  272. _describe -t commands gbp subcommands
  273. ;;
  274. (options)
  275. local funcname
  276. funcname=_gbp-$line[1]
  277. if type $funcname | grep -q "shell function" ; then
  278. $funcname
  279. fi
  280. ;;
  281. esac
  282. }
  283. _gbp-buildpackage() {
  284. __gbp_common_options git-
  285. __gbp_branch_options git-
  286. __gbp_tag_format_options git-
  287. __gbp_tag_sign_options git-
  288. _arguments \
  289. '--git-ignore-new[build with uncommited changes in the source tree]' \
  290. '--git-no-ignore-new[negates --git-ignore-new]' \
  291. '--git-tag[create a tag after a successful build]' \
  292. '--git-tag-only[do not build, only tag and run the posttag hook]' \
  293. '--git-retag[do not fail if the tag already exists]' \
  294. '--git-force-create[force creation of orig.tar.gz]' \
  295. '--git-no-create-orig[do not create orig.tar.gz]' \
  296. '--git-tarball-dir=-[location to look for external tarballs]:tarball directory:_files -/' \
  297. '--git-compression=-[compression type]:compression:(auto gzip bzip2 lzma xz)' \
  298. '--git-compression-level=-[set compression level]:level:(1 2 3 4 5 6 7 8 9)' \
  299. '--git-ignore-branch[build although debian-branch != current branch]' \
  300. '--git-no-ignore-branch[negates --git-ignore-branch]' \
  301. '--git-builder=-[command to build the Debian package]:command:' \
  302. '--git-cleaner=-[command to clean the working copy]:command:' \
  303. '--git-prebuild=-[command to run before a build]:command:' \
  304. '--git-postbuild=-[hook run after a successful build]:command:' \
  305. '--git-posttag=-[hook run after a successful tag operation]:command:' \
  306. '--git-pbuilder[invoke git-pbuilder for building]' \
  307. '--git-no-pbuilder[negates --git-pbuilder]' \
  308. '--git-dist=-[build for this distribution when using git-pbuilder]:distribution:' \
  309. '--git-arch=-[build for this architecture when using git-pbuilder]:architecture:' \
  310. '--git-export-dir=-[before building the package export the source into this directory]:directory:_files -/' \
  311. '--git-export=-[export treeish object instead of HEAD]:treeish:' \
  312. '--git-dont-purge[retain exported package build directory]' \
  313. '--git-overlay[extract orig tarball when using export-dir option]' \
  314. '--git-no-overlay[negates --git-overlay]' \
  315. '--git-notify=-[Send a desktop notification after build]:notify:(on auto off)' \
  316. '*:Other options:_dpkg-buildpackage'
  317. }
  318. _gbp-clone() {
  319. __gbp_common_options
  320. __gbp_branch_options
  321. _arguments \
  322. '--all[Track all branches, not only debian and upstream]'
  323. }
  324. _gbp-create-remote-repo() {
  325. __gbp_common_options
  326. _arguments \
  327. '--remote-url-pattern=-[Where to create remote repository]' \
  328. '--remote-name=-[What name git will use when refering to that repository]' \
  329. '--template-dir=-[Template dir to pass to git init]' \
  330. '--remote-config=-[Name of config file section to specify params]' \
  331. '(--track --no-track)--track[Set up branch tracking]' \
  332. '(--track --no-track)--no-track[Do not set up branch tracking]'
  333. }
  334. _gbp-dch () {
  335. __gbp_common_options
  336. __gbp_branch_options
  337. __gbp_tag_format_options
  338. _arguments \
  339. '--git-ignore-branch[build although debian-branch != current branch]' \
  340. '--since=-[Start point for reading commits]:commitish:' \
  341. '--auto[Guess the last commit documented in the changelog]' \
  342. '(--meta --no-meta)--meta[Parse meta tags]' \
  343. '(--meta --no-meta)--no-meta[Do not parse meta tags]' \
  344. '--meta-closes=-[What meta tags to look for to generate bug-closing changelog entries]' \
  345. '--meta-closes-bugnum=-[What bug number format to look for to generate bug-closing changelog entries]' \
  346. '(--full --no-full)--full[Include the full commit message]' \
  347. '(--full --no-full)--no-full[Do not include the full commit message]' \
  348. '(--snapshot -S)'{-S,--snapshot}'[Create a snapshot release entry]' \
  349. '--snapshot-number=-[Python expression that gets eval()ed to the new snapshot number]' \
  350. '(--release -R)'{-R,--release}'[Remove any snapshot release banners]' \
  351. '(--new-version -N)'{-R,--release}'=[Specify changelog version]' \
  352. '--team[Create a team upload entry]' \
  353. '--bpo[Increment the release number for a backports upload]' \
  354. '--nmu[Increment the release number for a NMU upload]' \
  355. '--qa[Increment the release number for a QA upload]' \
  356. '--distribution=-[Set the distribution field]' \
  357. '--force-distribution[Force distribution]' \
  358. '--urgency=-[Set the upload urgency]' \
  359. '--git-log=-[Options passed to git log]' \
  360. '--id-length=-[Number of commit id digits to include]' \
  361. '--ignore-regex=-[Ignore matching commit lines]' \
  362. '--git-author[Use git name configuration for changelog signature]' \
  363. '(--multimaint-merge --no-multimaint-merge)--multimaint-merge[Merge commits by maintainer]' \
  364. '(--multimaint-merge --no-multimaint-merge)--multimaint-merge[Do not merge commits by maintainer]' \
  365. '--spawn-editor=[Spawn an editor]:when:(always snapshot release)' \
  366. '--commit-msg=[Commit message format string]' \
  367. '--commit[Commit the generated changelog]' \
  368. '*:Paths:_files -/'
  369. }
  370. _gbp-import-dsc() {
  371. __gbp_common_options
  372. __gbp_branch_options
  373. __gbp_tag_format_options
  374. __gbp_tag_sign_options
  375. _arguments \
  376. '--filter=-[Filter out files]' \
  377. '--download=-[Download the source package]' \
  378. '--allow-unauthenticated[Skip signature verification on downloads]' \
  379. '--allow-same-version[Import a package with the same debian version]' \
  380. '--author-is-committer[Use the author identity as committer identity]' \
  381. '--author-date-is-committer-date[Use author date as commit date]' \
  382. '*:package:_files -g "*.dsc"'
  383. # TODO: complete source package names
  384. # TODO: pass only one tarball/source package name
  385. }
  386. _gbp-import-dscs() {
  387. # same options
  388. _gbp-import_dsc
  389. _arguments \
  390. '--debsnap[Fetch snapshots from snapshots.debian.org]' \
  391. '--ignore-repo-config[Ignore options in gbp.conf]'
  392. # TODO: multiple dscs or one source package name + debsnap
  393. }
  394. _gbp-import-orig() {
  395. __gbp_common_options
  396. __gbp_branch_options
  397. __gbp_tag_format_options
  398. __gbp_tag_sign_options
  399. _arguments \
  400. '(--upstream-version -u)'{--upstream-version,-u}'=[The upstream version number]' \
  401. '--merge[Merge the upstream branch into the debian branch]' \
  402. '--upstream-vcs-tag=-[Add a tag as an additional parent to the upstream tarball commit]' \
  403. '--import-msg=-[Commit message format string]' \
  404. '--filter=-[Filter out files]' \
  405. '--filter-pristine-tar[When filtering also filter out of pristine-tar tarballs]' \
  406. '(--symlink-orig --no-symlink-orig)--symlink-orig=[Create a symlink with a debian-compliant name]' \
  407. '(--symlink-orig --no-symlink-orig)--no-symlink-orig=[Do not create a symlink with a debian-compliant name]' \
  408. '--postimport=-[Run a command after import]' \
  409. '--uscan[Use uscan to fetch the new upstream version]' \
  410. '*:file:_files'
  411. # TODO: pass only one tarball
  412. # TODO: Do not complete files when uscan option is enabled
  413. }
  414. _gbp-pq() {
  415. __gbp_common_options
  416. _arguments \
  417. '(--patch-numbers --no-patch-numbers)--patch-numbers[Add numbers to patch files]' \
  418. '(--patch-numbers --no-patch-numbers)--no-patch-numbers[Do not add numbers to patch files]' \
  419. '--topic=-[Topic to use when importing a single patch]' \
  420. '--time-machine=-[Go back N commits trying to apply patch queue]'
  421. local -a pqcommands
  422. pqcommands=(
  423. 'import:Create a patch queue branch'
  424. 'export:Export the patches on the patch-queue branch'
  425. 'rebase:Rebase the patch-queue branch against the current branch'
  426. 'drop:Drop the patch queue'
  427. 'apply:Add a single patch to the patch-queue'
  428. 'switch:Switch to the patch-queue branch if on the base branch and viceversa'
  429. )
  430. # TODO: only display these commands once
  431. _describe -t pqcommands gbp-pq pqcommands
  432. }
  433. _gbp-pull() {
  434. __gbp_common_options
  435. __gbp_branch_options
  436. _arguments \
  437. '--force[Update even non fast-forward]' \
  438. '--redo-pq[Rebuild the patch queue]' \
  439. '--ignore-branch[Dont care if on a detached state]' \
  440. '--depth=-[Depth for deepening shallow clones]'
  441. }
  442. _gbp "$@"