2012-01-19 23:32:27 +01:00
|
|
|
#compdef git-hub
|
|
|
|
#autoload
|
|
|
|
|
|
|
|
local state remotes remote branches ret=1
|
|
|
|
|
|
|
|
_arguments -C -s -S \
|
|
|
|
'1::args:->remote' \
|
|
|
|
'2::args:->branch' && ret=0
|
|
|
|
|
|
|
|
case "$state" in
|
|
|
|
(remote)
|
|
|
|
remotes=($(
|
|
|
|
git config -l \
|
|
|
|
| grep 'remote\.[^.]*\.url' \
|
|
|
|
| cut -d'.' -f2))
|
|
|
|
_describe -t branch 'remotes' remotes && ret=0
|
|
|
|
;;
|
|
|
|
(branch)
|
|
|
|
remote="$words[(($CURRENT - 1))]"
|
|
|
|
branches=($(
|
2012-01-24 06:50:51 +01:00
|
|
|
git branch -r \
|
|
|
|
| sed \
|
|
|
|
-e "/${remote}\/HEAD -> ${remote}/d" \
|
|
|
|
-e "s/^[[:space:]]*${remote}\///g"
|
2012-01-19 23:32:27 +01:00
|
|
|
))
|
|
|
|
_describe -t branch 'branches' branches && ret=0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
return $ret
|
2012-01-21 01:48:24 +01:00
|
|
|
|