mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-12-22 17:28:01 +00:00
Simplify git-config calls
This commit is contained in:
parent
2bee82dc2a
commit
39a793af0a
@ -17,17 +17,15 @@ _arguments -C -s -S \
|
|||||||
|
|
||||||
case "$state" in
|
case "$state" in
|
||||||
(remote)
|
(remote)
|
||||||
remotes=($(
|
remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2))
|
||||||
git config --local --get-regexp 'remote.*.url' \
|
|
||||||
| awk 'BEGIN {FS="."} ; {print $2}'
|
|
||||||
))
|
|
||||||
_describe -t branch 'remotes' remotes && ret=0
|
_describe -t branch 'remotes' remotes && ret=0
|
||||||
;;
|
;;
|
||||||
(branch-or-tag)
|
(branch-or-tag)
|
||||||
remote="$words[(($CURRENT - 1))]"
|
remote="$words[(($CURRENT - 1))]"
|
||||||
|
|
||||||
branches_or_tags=($(
|
branches_or_tags=($(
|
||||||
git ls-remote --heads --tags "$remote" | awk '{print $2}'
|
git ls-remote --heads --tags "$remote" 2>/dev/null | cut -f2
|
||||||
))
|
))
|
||||||
|
|
||||||
branches=(HEAD ${${(M)branches_or_tags[@]##refs/heads/?##}##refs/heads/})
|
branches=(HEAD ${${(M)branches_or_tags[@]##refs/heads/?##}##refs/heads/})
|
||||||
|
@ -8,10 +8,7 @@
|
|||||||
local remotes remote references reference file url
|
local remotes remote references reference file url
|
||||||
|
|
||||||
remote="${1:-origin}"
|
remote="${1:-origin}"
|
||||||
remotes=($(
|
remotes=($(git config --get-regexp 'remote.*.url' | cut -d. -f2))
|
||||||
git config --local --get-regexp 'remote.*.url' \
|
|
||||||
| awk 'BEGIN {FS="."} ; {print $2}'
|
|
||||||
))
|
|
||||||
|
|
||||||
if (( $remotes[(i)$remote] == $#remotes + 1 )); then
|
if (( $remotes[(i)$remote] == $#remotes + 1 )); then
|
||||||
print "$0: remote not found: $remote" >&2
|
print "$0: remote not found: $remote" >&2
|
||||||
@ -19,7 +16,7 @@ if (( $remotes[(i)$remote] == $#remotes + 1 )); then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
url=$(
|
url=$(
|
||||||
git config --local --get "remote.${remote}.url" \
|
git config --get "remote.${remote}.url" \
|
||||||
| sed -En "s/(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p"
|
| sed -En "s/(git|https?)(@|:\/\/)github.com(:|\/)(.+)\/(.+).git/https:\/\/github.com\/\4\/\5/p"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user