[Pkg-zsh-devel] Bug#717002: zsh: Update for git-buildpackage completion

Felipe Sateler fsateler at debian.org
Mon Jul 15 21:27:37 UTC 2013

Package: zsh
Version: 5.0.2-3
Severity: wishlist

Git buildpackage has changed the preferred interface. I have taken a
stab at updating the current completion into the new interface. I also
took the time to add completion for the other gbp commands.

Unfortunately my completion foo is quite limited, so they are not as
good as they could be (multiple pq commands are allowed;
cannot detect when to require a dsc or a package name in import-dsc and

I still think the result is somewhat useful.

Find the completion attached

-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.9-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages zsh depends on:
ii  dpkg        1.16.10
ii  libc6       2.17-7
ii  libcap2     1:2.22-1.2
ii  libtinfo5   5.9+20130608-1
ii  zsh-common  5.0.2-3

Versions of packages zsh recommends:
ii  libncursesw5  5.9+20130608-1
ii  libpcre3      1:8.31-2

Versions of packages zsh suggests:
pn  zsh-doc  <none>

-- Configuration Files:
/etc/zsh/zshrc changed [not included]

-- no debconf information
-------------- next part --------------
#compdef 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
		#breaks if defined outside the func
		local -a 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
		local funcname
		if type $funcname | grep -q "shell function" ; then

_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 uncommited 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() {
	_arguments \
		'--all[Track all branches, not only debian and upstream]'

_gbp-create-remote-repo() {
	_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 () {
	_arguments \
		'--git-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]' \
		'(--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 snapshot release)' \
		'--commit-msg=[Commit message format string]' \
		'--commit[Commit the generated changelog]' \
		'*:Paths:_files -/'

_gbp-import-dsc() {
	_arguments \
		'--filter=-[Filter out files]' \
		'--download=-[Download the source package]' \
		'--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
	_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() {
	_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]' \
	# TODO: pass only one tarball
	# TODO: Do not complete files when uscan option is enabled

_gbp-pq() {
	_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
		'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() {
	_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 "$@"

More information about the Pkg-zsh-devel mailing list