mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-22 04:51:12 +02:00
only check connectivity when an update is needed
This commit is contained in:
parent
b4fc92cf0c
commit
0b1716e5cd
1 changed files with 12 additions and 12 deletions
|
|
@ -11,6 +11,18 @@ function _update_zsh_update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _upgrade_zsh() {
|
function _upgrade_zsh() {
|
||||||
|
# Skip when no internet connectivity, depends on curl
|
||||||
|
REMOTE=$(cd "$ZSH" && git remote get-url --all origin)
|
||||||
|
echo "$REMOTE" | grep -qa 'git@'
|
||||||
|
if [ $? -eq 0 ]
|
||||||
|
then
|
||||||
|
# convert the remote protocol to https
|
||||||
|
REMOTE=$(echo $REMOTE | tr ':' '/' | sed -e "s#git@#https://#")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# -L follow redirect, -s silent,
|
||||||
|
# --max-time overall operation timeout, -I only download headers
|
||||||
|
whence curl > /dev/null && curl -L -s --max-time 3 -I ${REMOTE} > /dev/null || return 0
|
||||||
env ZSH=$ZSH sh $ZSH/tools/upgrade.sh
|
env ZSH=$ZSH sh $ZSH/tools/upgrade.sh
|
||||||
# update the zsh file
|
# update the zsh file
|
||||||
_update_zsh_update
|
_update_zsh_update
|
||||||
|
|
@ -29,18 +41,6 @@ fi
|
||||||
# Cancel upgrade if git is unavailable on the system
|
# Cancel upgrade if git is unavailable on the system
|
||||||
whence git >/dev/null || return 0
|
whence git >/dev/null || return 0
|
||||||
|
|
||||||
# Skip when no internet connectivity, depends on curl
|
|
||||||
REMOTE=$(cd "$ZSH" && git remote get-url --all origin)
|
|
||||||
echo "$REMOTE" | grep -qa 'git@'
|
|
||||||
if [ $? -eq 0 ]
|
|
||||||
then
|
|
||||||
# convert the remote protocol to https
|
|
||||||
REMOTE=$(echo $REMOTE | tr ':' '/' | sed -e "s#git@#https://#")
|
|
||||||
fi
|
|
||||||
# -L follow redirect, -s silent,
|
|
||||||
# --max-time overall operation timeout, -I only download headers
|
|
||||||
whence curl > /dev/null && curl -L -s --max-time 3 -I ${REMOTE} > /dev/null || return 0
|
|
||||||
|
|
||||||
if mkdir "$ZSH/log/update.lock" 2>/dev/null; then
|
if mkdir "$ZSH/log/update.lock" 2>/dev/null; then
|
||||||
if [ -f ~/.zsh-update ]; then
|
if [ -f ~/.zsh-update ]; then
|
||||||
. ~/.zsh-update
|
. ~/.zsh-update
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue