}
+_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'
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" == "=" ]]
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))
}
{
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
{
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
{
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
{
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