2012-09-29 20:00:38 +02:00
|
|
|
#compdef git-hub-browse
|
2012-01-19 23:32:27 +01:00
|
|
|
#autoload
|
|
|
|
|
2012-02-01 05:37:51 +01:00
|
|
|
#
|
2012-09-25 07:46:41 +02:00
|
|
|
# Completes git-hub-browse.
|
2012-02-01 05:37:51 +01:00
|
|
|
#
|
|
|
|
# Authors:
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
|
|
|
#
|
|
|
|
|
2012-09-29 19:42:15 +02:00
|
|
|
local state expl remotes remote branches_or_tags branches tags files ret=1
|
2012-01-19 23:32:27 +01:00
|
|
|
|
|
|
|
_arguments -C -s -S \
|
|
|
|
'1::args:->remote' \
|
2012-09-24 23:57:48 +02:00
|
|
|
'2::args:->branch-or-tag' \
|
2012-02-03 00:25:21 +01:00
|
|
|
'3::args:->file' && ret=0
|
2012-01-19 23:32:27 +01:00
|
|
|
|
|
|
|
case "$state" in
|
|
|
|
(remote)
|
|
|
|
remotes=($(
|
2012-09-24 07:46:24 +02:00
|
|
|
git config --local --get-regexp 'remote.*.url' \
|
|
|
|
| awk 'BEGIN {FS="."} ; {print $2}'
|
|
|
|
))
|
2012-01-19 23:32:27 +01:00
|
|
|
_describe -t branch 'remotes' remotes && ret=0
|
|
|
|
;;
|
2012-09-24 23:57:48 +02:00
|
|
|
(branch-or-tag)
|
2012-01-19 23:32:27 +01:00
|
|
|
remote="$words[(($CURRENT - 1))]"
|
2012-09-24 23:57:48 +02:00
|
|
|
|
|
|
|
branches_or_tags=($(
|
|
|
|
git ls-remote --heads --tags "$remote" | awk '{print $2}'
|
2012-01-19 23:32:27 +01:00
|
|
|
))
|
2012-09-24 23:57:48 +02:00
|
|
|
|
|
|
|
branches=(HEAD ${${(M)branches_or_tags[@]##refs/heads/?##}##refs/heads/})
|
|
|
|
tags=(${${(M)branches_or_tags[@]##refs/tags/?##}##refs/tags/})
|
|
|
|
|
2012-01-19 23:32:27 +01:00
|
|
|
_describe -t branch 'branches' branches && ret=0
|
2012-09-24 23:57:48 +02:00
|
|
|
_describe -t tag 'tags' tags && ret=0
|
2012-01-19 23:32:27 +01:00
|
|
|
;;
|
2012-02-03 00:25:21 +01:00
|
|
|
(file)
|
|
|
|
files=(${(0)"$(_call_program files git ls-files -z --exclude-standard 2>/dev/null)"})
|
|
|
|
_wanted file expl 'file' _multi_parts - / files && ret=0
|
|
|
|
;;
|
2012-01-19 23:32:27 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
return $ret
|
2012-01-21 01:48:24 +01:00
|
|
|
|