aboutsummaryrefslogtreecommitdiffhomepage
path: root/debian/git-buildpackage.zsh-completion
blob: 196a37ebe7e7ffe85865c26a60bb42170b7dc6b0 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
#compdef gbp
#description build Debian packages from a Git repository

__gbp_common_options() {
	local prefix="$1"
	# these can't be prefixed
	_arguments '--help[Show help]' \
		'--version[Show version information]'

	_arguments "--${prefix}verbose[Verbose execution]" \
		"--${prefix}color=-[Use colored output]:color:(on auto off)"

}

__gbp_branch_options() {
	local prefix="$1"
	_arguments \
		"--${prefix}debian-branch=-[The branch the Debian package is being developed on]" \
		"--${prefix}upstream-branch=-[The branch the upstream  sources  are  put onto]" \
		"--${prefix}pristine-tar[Track pristine tar branch]"
}

__gbp_tag_format_options() {
	local prefix="$1"
	_arguments \
		"--${prefix}debian-tag=-[format string for debian tags]" \
		"--${prefix}upstream-tag=-[format string for upstream tags]"
}

__gbp_tag_sign_options() {
	local prefix="$1"
	_arguments \
		"(--${prefix}sign-tags --${prefix}no-sign-tags)--${prefix}sign-tags[GPG sign all generated tags]" \
		"(--${prefix}sign-tags --${prefix}no-sign-tags)--${prefix}no-sign-tags[Do not GPG sign generated tags]" \
		"--${prefix}keyid=-[GPG keyid to sign tags with]:GPG key:"
}

_gbp() {
	local curcontext="$curcontext" state line
	typeset -A opt_args
	_arguments -C \
		':command:->command' \
		'*::options:->options' \

	case $state in
	(command)
		#breaks if defined outside the func
		local -a subcommands
		subcommands=(
			'buildpackage:Build a Debian package'
			'clone:Clone  a  Git  repository from a remote and set up the necessary branch tracking.'
			'create-remote-repo:Create a remote Git repository'
			'dch:Generate the debian/changelog from  Git commit history'
			'import-dsc:Import a single Debian source package'
			'import-dscs:Import multiple Debian source packages'
			'import-orig:Import a new upstream tarball'
			'pq:Manage debian/patches using Git rebase'
			'pull:Update a Git repository from a remote'
		)

		_describe -t commands gbp subcommands
	;;
	(options)
		local funcname
		funcname=_gbp-$line[1]
		if type $funcname | grep -q "shell function" ; then
			$funcname
		fi
	;;
	esac
}

_gbp-buildpackage() {
	__gbp_common_options git-
	__gbp_branch_options git-
	__gbp_tag_format_options git-
	__gbp_tag_sign_options git-
	_arguments \
	  '--git-ignore-new[build with uncommitted changes in the source tree]' \
	  '--git-no-ignore-new[negates --git-ignore-new]' \
	  '--git-tag[create a tag after a successful build]' \
	  '--git-tag-only[do not build, only tag and run the posttag hook]' \
	  '--git-retag[do not fail if the tag already exists]' \
	  '--git-force-create[force creation of orig.tar.gz]' \
	  '--git-no-create-orig[do not create orig.tar.gz]' \
	  '--git-tarball-dir=-[location to look for external tarballs]:tarball directory:_files -/' \
	  '--git-compression=-[compression type]:compression:(auto gzip bzip2 lzma xz)' \
	  '--git-compression-level=-[set compression level]:level:(1 2 3 4 5 6 7 8 9)' \
	  '--git-ignore-branch[build although debian-branch != current branch]' \
	  '--git-no-ignore-branch[negates --git-ignore-branch]' \
	  '--git-builder=-[command to build the Debian package]:command:' \
	  '--git-cleaner=-[command to clean the working copy]:command:' \
	  '--git-prebuild=-[command to run before a build]:command:' \
	  '--git-postbuild=-[hook run after a successful build]:command:' \
	  '--git-posttag=-[hook run after a successful tag operation]:command:' \
	  '--git-pbuilder[invoke git-pbuilder for building]' \
	  '--git-no-pbuilder[negates --git-pbuilder]' \
	  '--git-dist=-[build for this distribution when using git-pbuilder]:distribution:' \
	  '--git-arch=-[build for this architecture when using git-pbuilder]:architecture:' \
	  '--git-export-dir=-[before building the package export the source into this directory]:directory:_files -/' \
	  '--git-export=-[export treeish object instead of HEAD]:treeish:' \
	  '--git-dont-purge[retain exported package build directory]' \
	  '--git-overlay[extract orig tarball when using export-dir option]' \
	  '--git-no-overlay[negates --git-overlay]' \
	  '--git-notify=-[Send a desktop notification after build]:notify:(on auto off)' \
	  '*:Other options:_dpkg-buildpackage'
}

_gbp-clone() {
	__gbp_common_options
	__gbp_branch_options
	_arguments \
		'--all[Track all branches, not only debian and upstream]'
}

_gbp-create-remote-repo() {
	__gbp_common_options
	_arguments \
		'--remote-url-pattern=-[Where to create remote repository]' \
		'--remote-name=-[What  name  git  will use when refering to that repository]' \
		'--template-dir=-[Template dir to pass to git init]' \
		'--remote-config=-[Name of config file section to specify params]' \
		'(--track --no-track)--track[Set up branch tracking]' \
		'(--track --no-track)--no-track[Do not set up branch tracking]'

}

_gbp-dch () {
	__gbp_common_options
	__gbp_branch_options
	__gbp_tag_format_options

	_arguments \
		'--ignore-branch[build although debian-branch != current branch]' \
		'--since=-[Start point for reading commits]:commitish:' \
		'--auto[Guess the last commit documented in the changelog]' \
		'(--meta --no-meta)--meta[Parse meta tags]' \
		'(--meta --no-meta)--no-meta[Do not parse meta tags]' \
		'--meta-closes=-[What meta tags to look for  to  generate  bug-closing  changelog entries]' \
		'--meta-closes-bugnum=-[What bug number format to look for to generate bug-closing changelog entries]' \
		'(--full --no-full)--full[Include the full commit message]' \
		'(--full --no-full)--no-full[Do not include the full commit message]' \
		'(--snapshot -S)'{-S,--snapshot}'[Create a snapshot release entry]' \
		'--snapshot-number=-[Python expression that gets eval()ed to the new snapshot number]' \
		'(--release -R)'{-R,--release}'[Remove any snapshot release banners]' \
		'(--new-version -N)'{-R,--release}'=[Specify changelog version]' \
		'--team[Create a team upload entry]' \
		'--bpo[Increment the release number for a backports upload]' \
		'--nmu[Increment the release number for a NMU upload]' \
		'--qa[Increment the release number for a QA upload]' \
		'--distribution=-[Set the distribution field]' \
		'--force-distribution[Force distribution]' \
		'--urgency=-[Set the upload urgency]' \
		'--git-log=-[Options passed to git log]' \
		'--id-length=-[Number of commit id digits to include]' \
		'--ignore-regex=-[Ignore matching commit lines]' \
		'--git-author[Use git name configuration for changelog signature]' \
		'(--multimaint-merge --no-multimaint-merge)--multimaint-merge[Merge commits by maintainer]' \
		'(--multimaint-merge --no-multimaint-merge)--multimaint-merge[Do not merge commits by maintainer]' \
		'--spawn-editor=[Spawn an editor]:when:(always never snapshot release)' \
		'--commit-msg=[Commit message format string]' \
		'--commit[Commit the generated changelog]' \
		'*:Paths:_files -/'
}

_gbp-import-dsc() {
	__gbp_common_options
	__gbp_branch_options
	__gbp_tag_format_options
	__gbp_tag_sign_options
	_arguments \
		'--filter=-[Filter out files]' \
		'--allow-unauthenticated[Skip signature verification on downloads]' \
		'--allow-same-version[Import a package with the same debian version]' \
		'--author-is-committer[Use the author identity as committer identity]' \
		'--author-date-is-committer-date[Use author date as commit date]' \
		'*:package:_files -g "*.dsc"'
	# TODO: complete source package names
	# TODO: pass only one tarball/source package name
}

_gbp-import-dscs() {
	# same options
	_gbp-import-dsc
	_arguments \
		'--debsnap[Fetch snapshots from snapshots.debian.org]' \
		'--ignore-repo-config[Ignore options in gbp.conf]'
	# TODO: multiple dscs or one source package name + debsnap
}

_gbp-import-orig() {
	__gbp_common_options
	__gbp_branch_options
	__gbp_tag_format_options
	__gbp_tag_sign_options
	_arguments \
		'(--upstream-version -u)'{--upstream-version,-u}'=[The upstream version number]' \
		'--merge[Merge the upstream branch into the debian branch]' \
		'--upstream-vcs-tag=-[Add a tag as an additional parent to the upstream tarball commit]' \
		'--import-msg=-[Commit message format string]' \
		'--filter=-[Filter out files]' \
		'--filter-pristine-tar[When filtering also filter out of pristine-tar tarballs]' \
		'(--symlink-orig --no-symlink-orig)--symlink-orig=[Create a symlink with a debian-compliant name]' \
		'(--symlink-orig --no-symlink-orig)--no-symlink-orig=[Do not create a symlink with a debian-compliant name]' \
		'--postimport=-[Run a command after import]' \
		'--uscan[Use uscan to fetch the new upstream version]' \
		'*:file:_files'

	# TODO: pass only one tarball
	# TODO: Do not complete files when uscan option is enabled
}

_gbp-pq() {
	__gbp_common_options
	_arguments \
		'(--patch-numbers --no-patch-numbers)--patch-numbers[Add numbers to patch files]' \
		'(--patch-numbers --no-patch-numbers)--no-patch-numbers[Do not add numbers to patch files]' \
		'--topic=-[Topic to use when importing a single patch]' \
		'--time-machine=-[Go back N commits trying to apply patch queue]'

	local -a pqcommands
	pqcommands=(
		'import:Create   a   patch   queue   branch'
		'export:Export the patches on the patch-queue branch'
		'rebase:Rebase the  patch-queue  branch against the current branch'
		'drop:Drop the patch queue'
		'apply:Add  a  single patch to the patch-queue'
		'switch:Switch to the patch-queue branch if on the base branch and viceversa'
	)
	# TODO: only display these commands once
	_describe -t pqcommands gbp-pq pqcommands
}

_gbp-pull() {
	__gbp_common_options
	__gbp_branch_options
	_arguments \
		'--force[Update even non fast-forward]' \
		'--redo-pq[Rebuild the patch queue]' \
		'--ignore-branch[Dont care if on a detached state]' \
		'--depth=-[Depth for deepening shallow clones]'
}

_gbp "$@"



__gbp_common_options() {
	local prefix="$1"
	# these can't be prefixed
	_arguments '--help[Show help]' \
		'--version[Show version information]'

	_arguments "--${prefix}verbose[Verbose execution]" \
		"--${prefix}color=-[Use colored output]:color:(on auto off)"

}

__gbp_branch_options() {
	local prefix="$1"
	_arguments \
		"--${prefix}debian-branch=-[The branch the Debian package is being developed on]" \
		"--${prefix}upstream-branch=-[The branch the upstream  sources  are  put onto]" \
		"--${prefix}pristine-tar[Track pristine tar branch]"
}

__gbp_tag_format_options() {
	local prefix="$1"
	_arguments \
		"--${prefix}debian-tag=-[format string for debian tags]" \
		"--${prefix}upstream-tag=-[format string for upstream tags]"
}

__gbp_tag_sign_options() {
	local prefix="$1"
	_arguments \
		"(--${prefix}sign-tags --${prefix}no-sign-tags)--${prefix}sign-tags[GPG sign all generated tags]" \
		"(--${prefix}sign-tags --${prefix}no-sign-tags)--${prefix}no-sign-tags[Do not GPG sign generated tags]" \
		"--${prefix}keyid=-[GPG keyid to sign tags with]:GPG key:"
}

_gbp() {
	local curcontext="$curcontext" state line
	typeset -A opt_args
	_arguments -C \
		':command:->command' \
		'*::options:->options' \

	case $state in
	(command)
		#breaks if defined outside the func
		local -a subcommands
		subcommands=(
			'buildpackage:Build a Debian package'
			'clone:Clone  a  Git  repository from a remote and set up the necessary branch tracking.'
			'create-remote-repo:Create a remote Git repository'
			'dch:Generate the debian/changelog from  Git commit history'
			'import-dsc:Import a single Debian source package'
			'import-dscs:Import multiple Debian source packages'
			'import-orig:Import a new upstream tarball'
			'pq:Manage debian/patches using Git rebase'
			'pull:Update a Git repository from a remote'
		)

		_describe -t commands gbp subcommands
	;;
	(options)
		local funcname
		funcname=_gbp-$line[1]
		if type $funcname | grep -q "shell function" ; then
			$funcname
		fi
	;;
	esac
}

_gbp-buildpackage() {
	__gbp_common_options git-
	__gbp_branch_options git-
	__gbp_tag_format_options git-
	__gbp_tag_sign_options git-
	_arguments \
	  '--git-ignore-new[build with uncommitted changes in the source tree]' \
	  '--git-no-ignore-new[negates --git-ignore-new]' \
	  '--git-tag[create a tag after a successful build]' \
	  '--git-tag-only[do not build, only tag and run the posttag hook]' \
	  '--git-retag[do not fail if the tag already exists]' \
	  '--git-force-create[force creation of orig.tar.gz]' \
	  '--git-no-create-orig[do not create orig.tar.gz]' \
	  '--git-tarball-dir=-[location to look for external tarballs]:tarball directory:_files -/' \
	  '--git-compression=-[compression type]:compression:(auto gzip bzip2 lzma xz)' \
	  '--git-compression-level=-[set compression level]:level:(1 2 3 4 5 6 7 8 9)' \
	  '--git-ignore-branch[build although debian-branch != current branch]' \
	  '--git-no-ignore-branch[negates --git-ignore-branch]' \
	  '--git-builder=-[command to build the Debian package]:command:' \
	  '--git-cleaner=-[command to clean the working copy]:command:' \
	  '--git-prebuild=-[command to run before a build]:command:' \
	  '--git-postbuild=-[hook run after a successful build]:command:' \
	  '--git-posttag=-[hook run after a successful tag operation]:command:' \
	  '--git-pbuilder[invoke git-pbuilder for building]' \
	  '--git-no-pbuilder[negates --git-pbuilder]' \
	  '--git-dist=-[build for this distribution when using git-pbuilder]:distribution:' \
	  '--git-arch=-[build for this architecture when using git-pbuilder]:architecture:' \
	  '--git-export-dir=-[before building the package export the source into this directory]:directory:_files -/' \
	  '--git-export=-[export treeish object instead of HEAD]:treeish:' \
	  '--git-dont-purge[retain exported package build directory]' \
	  '--git-overlay[extract orig tarball when using export-dir option]' \
	  '--git-no-overlay[negates --git-overlay]' \
	  '--git-notify=-[Send a desktop notification after build]:notify:(on auto off)' \
	  '*:Other options:_dpkg-buildpackage'
}

_gbp-clone() {
	__gbp_common_options
	__gbp_branch_options
	_arguments \
		'--all[Track all branches, not only debian and upstream]'
}

_gbp-create-remote-repo() {
	__gbp_common_options
	_arguments \
		'--remote-url-pattern=-[Where to create remote repository]' \
		'--remote-name=-[What  name  git  will use when refering to that repository]' \
		'--template-dir=-[Template dir to pass to git init]' \
		'--remote-config=-[Name of config file section to specify params]' \
		'(--track --no-track)--track[Set up branch tracking]' \
		'(--track --no-track)--no-track[Do not set up branch tracking]'

}

_gbp-dch () {
	__gbp_common_options
	__gbp_branch_options
	__gbp_tag_format_options

	_arguments \
		'--ignore-branch[build although debian-branch != current branch]' \
		'--since=-[Start point for reading commits]:commitish:' \
		'--auto[Guess the last commit documented in the changelog]' \
		'(--meta --no-meta)--meta[Parse meta tags]' \
		'(--meta --no-meta)--no-meta[Do not parse meta tags]' \
		'--meta-closes=-[What meta tags to look for  to  generate  bug-closing  changelog entries]' \
		'--meta-closes-bugnum=-[What bug number format to look for to generate bug-closing changelog entries]' \
		'(--full --no-full)--full[Include the full commit message]' \
		'(--full --no-full)--no-full[Do not include the full commit message]' \
		'(--snapshot -S)'{-S,--snapshot}'[Create a snapshot release entry]' \
		'--snapshot-number=-[Python expression that gets eval()ed to the new snapshot number]' \
		'(--release -R)'{-R,--release}'[Remove any snapshot release banners]' \
		'(--new-version -N)'{-R,--release}'=[Specify changelog version]' \
		'--team[Create a team upload entry]' \
		'--bpo[Increment the release number for a backports upload]' \
		'--nmu[Increment the release number for a NMU upload]' \
		'--qa[Increment the release number for a QA upload]' \
		'--distribution=-[Set the distribution field]' \
		'--force-distribution[Force distribution]' \
		'--urgency=-[Set the upload urgency]' \
		'--git-log=-[Options passed to git log]' \
		'--id-length=-[Number of commit id digits to include]' \
		'--ignore-regex=-[Ignore matching commit lines]' \
		'--git-author[Use git name configuration for changelog signature]' \
		'(--multimaint-merge --no-multimaint-merge)--multimaint-merge[Merge commits by maintainer]' \
		'(--multimaint-merge --no-multimaint-merge)--multimaint-merge[Do not merge commits by maintainer]' \
		'--spawn-editor=[Spawn an editor]:when:(always never snapshot release)' \
		'--commit-msg=[Commit message format string]' \
		'--commit[Commit the generated changelog]' \
		'*:Paths:_files -/'
}

_gbp-import-dsc() {
	__gbp_common_options
	__gbp_branch_options
	__gbp_tag_format_options
	__gbp_tag_sign_options
	_arguments \
		'--filter=-[Filter out files]' \
		'--allow-unauthenticated[Skip signature verification on downloads]' \
		'--allow-same-version[Import a package with the same debian version]' \
		'--author-is-committer[Use the author identity as committer identity]' \
		'--author-date-is-committer-date[Use author date as commit date]' \
		'*:package:_files -g "*.dsc"'
	# TODO: complete source package names
	# TODO: pass only one tarball/source package name
}

_gbp-import-dscs() {
	# same options
	_gbp-import-dsc
	_arguments \
		'--debsnap[Fetch snapshots from snapshots.debian.org]' \
		'--ignore-repo-config[Ignore options in gbp.conf]'
	# TODO: multiple dscs or one source package name + debsnap
}

_gbp-import-orig() {
	__gbp_common_options
	__gbp_branch_options
	__gbp_tag_format_options
	__gbp_tag_sign_options
	_arguments \
		'(--upstream-version -u)'{--upstream-version,-u}'=[The upstream version number]' \
		'--merge[Merge the upstream branch into the debian branch]' \
		'--upstream-vcs-tag=-[Add a tag as an additional parent to the upstream tarball commit]' \
		'--import-msg=-[Commit message format string]' \
		'--filter=-[Filter out files]' \
		'--filter-pristine-tar[When filtering also filter out of pristine-tar tarballs]' \
		'(--symlink-orig --no-symlink-orig)--symlink-orig=[Create a symlink with a debian-compliant name]' \
		'(--symlink-orig --no-symlink-orig)--no-symlink-orig=[Do not create a symlink with a debian-compliant name]' \
		'--postimport=-[Run a command after import]' \
		'--uscan[Use uscan to fetch the new upstream version]' \
		'*:file:_files'

	# TODO: pass only one tarball
	# TODO: Do not complete files when uscan option is enabled
}

_gbp-pq() {
	__gbp_common_options
	_arguments \
		'(--patch-numbers --no-patch-numbers)--patch-numbers[Add numbers to patch files]' \
		'(--patch-numbers --no-patch-numbers)--no-patch-numbers[Do not add numbers to patch files]' \
		'--topic=-[Topic to use when importing a single patch]' \
		'--time-machine=-[Go back N commits trying to apply patch queue]'

	local -a pqcommands
	pqcommands=(
		'import:Create   a   patch   queue   branch'
		'export:Export the patches on the patch-queue branch'
		'rebase:Rebase the  patch-queue  branch against the current branch'
		'drop:Drop the patch queue'
		'apply:Add  a  single patch to the patch-queue'
		'switch:Switch to the patch-queue branch if on the base branch and viceversa'
	)
	# TODO: only display these commands once
	_describe -t pqcommands gbp-pq pqcommands
}

_gbp-pull() {
	__gbp_common_options
	__gbp_branch_options
	_arguments \
		'--force[Update even non fast-forward]' \
		'--redo-pq[Rebuild the patch queue]' \
		'--ignore-branch[Dont care if on a detached state]' \
		'--depth=-[Depth for deepening shallow clones]'
}

_gbp "$@"