Package: gitpkg
Version: 0.21
Severity: wishlist
Tags: patch

Hello.

I've written a "gitpkg" bash completion file. Please include it, to
get tab completion of git tags and branches when using gitpkg.

Thanks,
Stig Sandbeck Mathisen

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (900, 'testing')
Architecture: amd64 (x86_64)

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

Versions of packages gitpkg depends on:
ii  dpkg-dev  1.16.3
ii  git       1:1.7.10-1

gitpkg recommends no packages.

Versions of packages gitpkg suggests:
ii  devscripts  2.11.7

-- no debconf information
# -*- shell-script -*-
#
# Bash tab auto-completion rules for gitpkg
#
# Copyright © 2012 Stig Sandbeck Mathisen <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.


have gitpkg &&
_gitpkg_names () {

    if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" != "true" ]; then
      return 0
    fi

    local cur options names

    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    options='--help --version'

    if [[ "${cur}" == -* ]]; then
        COMPREPLY=( $( compgen -W "${options}" -- "${cur}" ) )
    else
        names=$(
            {
                git for-each-ref --format='%(refname:short)' refs/heads
                git for-each-ref --format='%(refname:short)' refs/tags
            } | sort -u
        )
        COMPREPLY=( $( compgen -W "${names}" -- "${cur}" ) )
    fi

    return 0
}

[ -n "${have:-}" ] && complete -F _gitpkg_names gitpkg

Reply via email to