Use Git porcelain commands in git-hub

This commit is contained in:
Sorin Ionescu 2012-09-24 01:46:24 -04:00
parent 4cc8167739
commit 224dc2eaff
2 changed files with 9 additions and 12 deletions

View file

@ -18,19 +18,16 @@ _arguments -C -s -S \
case "$state" in case "$state" in
(remote) (remote)
remotes=($( remotes=($(
git config -l \ git config --local --get-regexp 'remote.*.url' \
| grep 'remote\.[^.]*\.url' \ | awk 'BEGIN {FS="."} ; {print $2}'
| cut -d'.' -f2)) ))
_describe -t branch 'remotes' remotes && ret=0 _describe -t branch 'remotes' remotes && ret=0
;; ;;
(branch) (branch)
remote="$words[(($CURRENT - 1))]" remote="$words[(($CURRENT - 1))]"
branches=($( branches=($(
git branch -r \ git ls-remote --heads "$remote" \
| grep "${remote}/" \ | awk '{gsub(/refs\/heads\//, "", $2)} ; {print $2}'
| sed \
-e "/${remote}\/HEAD -> ${remote}/d" \
-e "s/^[[:space:]]*${remote}\///g"
)) ))
_describe -t branch 'branches' branches && ret=0 _describe -t branch 'branches' branches && ret=0
;; ;;

View file

@ -9,12 +9,12 @@ local remote branches branch current_branch file url
remote="${1:-origin}" remote="${1:-origin}"
url=$( url=$(
git config -l \ git config --local --get "remote.${remote}.url" \
| grep "remote.${remote}.url" \ | sed -En "s/(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p"
| sed -En "s/remote.${remote}.url=(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p"
) )
branches=($( branches=($(
git branch -r | sed -e "/${remote}\/HEAD -> ${remote}/d" -e "s/^[[:space:]]*${remote}\///g" git ls-remote --heads "$remote" \
| awk '{gsub(/refs\/heads\//, "", $2)} ; {print $2}'
)) ))
current_branch="$(git-branch-current)" current_branch="$(git-branch-current)"
branch="${2:-master}" branch="${2:-master}"