diff options
author | Guido Günther <agx@sigxcpu.org> | 2011-01-03 22:47:30 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2011-01-03 22:48:20 +0100 |
commit | 7374d00b74c60a2d7574216711c4b835d8711b5a (patch) | |
tree | cbfc1e19bd2f2bb24f2d761ec61342aee27de93a | |
parent | 9411f76977926a5a99ff5fbda7417c2af21f4dcd (diff) | |
download | git-buildpackage-7374d00b74c60a2d7574216711c4b835d8711b5a.tar.gz git-buildpackage-7374d00b74c60a2d7574216711c4b835d8711b5a.tar.bz2 git-buildpackage-7374d00b74c60a2d7574216711c4b835d8711b5a.zip |
bash completion: also complete on tags
-rw-r--r-- | debian/git-buildpackage.bash-completion | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/debian/git-buildpackage.bash-completion b/debian/git-buildpackage.bash-completion index ff71753c..653c412e 100644 --- a/debian/git-buildpackage.bash-completion +++ b/debian/git-buildpackage.bash-completion @@ -14,6 +14,13 @@ _gbp_branches () } +_gbp_tags () +{ + [ -d .git ] || return 0 + git for-each-ref --format="%(refname:short)" refs/tags +} + + _gbp_options () { $1 --help | sed -ne 's/^ \+\(\(\-[a-z]\), \)\?\(\-\-[a-z\-]\+\=\?\).*/\2 \3/p' @@ -26,6 +33,7 @@ _gbp_comp () local prev="${COMP_WORDS[COMP_CWORD - 1]}" local options=$1 local branch_opts=$2 + local tag_opts=$3 # COMPREPLY considers '=' as a word. For $prev we prefer the word before the actual "=" if [[ "$prev" == "=" ]] @@ -42,6 +50,12 @@ _gbp_comp () return 0 fi + if [[ "${tag_opts}" == *$prev* ]]; then + local refs=$(_gbp_tags) + COMPREPLY=( $(compgen -W "$refs" -- $cur ) ) + return 0 + fi + COMPREPLY=($(compgen -W "$options" -- $cur)) } @@ -51,8 +65,9 @@ _git_buildpackage() { local options=$(_gbp_options git-buildpackage) local branch_opts="--git-debian-branch\= --git-upstream-branch\=" + local tag_opts="--git-debian-tag\= --git-upstream-tag\=" - _gbp_comp "$options" "$branch_opts" + _gbp_comp "$options" "$branch_opts" "$tag_opts" } [ "${have:-}" ] && complete -F _git_buildpackage -o default git-buildpackage @@ -62,8 +77,9 @@ _git_dch () { local options=$(_gbp_options git-dch) local branch_opts="--debian-branch\=" + local tag_opts="--debian-tag\= --upstream-tag\=" - _gbp_comp "$options" "$branch_opts" + _gbp_comp "$options" "$branch_opts" "$tag_opts" } [ "${have:-}" ] && complete -F _git_dch -o default git-dch @@ -73,8 +89,9 @@ _git_import_orig () { local options=$(_gbp_options git-import-orig) local branch_opts="--debian-branch\= --upstream-branch\=" + local tag_opts="--debian-tag\= --upstream-tag\=" - _gbp_comp "$options" "$branch_opts" + _gbp_comp "$options" "$branch_opts" "$tag_opts" } [ "${have:-}" ] && complete -F _git_import_orig -o default git-import-orig @@ -84,8 +101,9 @@ _git_import_dsc () { local options=$(_gbp_options git-import-dsc) local branch_opts="--debian-branch\= --upstream-branch\=" + local tag_opts="--debian-tag\= --upstream-tag\=" - _gbp_comp "$options" "$branch_opts" + _gbp_comp "$options" "$branch_opts" "$tag_opts" } [ "${have:-}" ] && complete -F _git_import_dsc -o default git-import-dsc |