mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
fix(updater): abort update if $ZSH
is not a git repository
Fixes #12298
This commit is contained in:
parent
c262ffbb68
commit
56cfcb44e7
2 changed files with 17 additions and 5 deletions
12
lib/cli.zsh
12
lib/cli.zsh
|
@ -773,7 +773,17 @@ function _omz::theme::use {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omz::update {
|
function _omz::update {
|
||||||
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD)
|
# Check if git command is available
|
||||||
|
(( $+commands[git] )) || {
|
||||||
|
_omz::log error "git is not installed. Aborting..."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
local last_commit=$(builtin cd -q "$ZSH"; git rev-parse HEAD 2>/dev/null)
|
||||||
|
[[ $? -eq 0 ]] || {
|
||||||
|
_omz::log error "\`$ZSH\` is not a git directory. Aborting..."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
# Run update script
|
# Run update script
|
||||||
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default
|
||||||
|
|
|
@ -20,14 +20,16 @@ zstyle -s ':omz:update' mode update_mode || {
|
||||||
}
|
}
|
||||||
|
|
||||||
# Cancel update if:
|
# Cancel update if:
|
||||||
# - the automatic update is disabled.
|
# - the automatic update is disabled
|
||||||
# - the current user doesn't have write permissions nor owns the $ZSH directory.
|
# - the current user doesn't have write permissions nor owns the $ZSH directory
|
||||||
# - is not run from a tty
|
# - is not run from a tty
|
||||||
# - git is unavailable on the system.
|
# - git is unavailable on the system
|
||||||
|
# - $ZSH is not a git repository
|
||||||
if [[ "$update_mode" = disabled ]] \
|
if [[ "$update_mode" = disabled ]] \
|
||||||
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
|
|| [[ ! -w "$ZSH" || ! -O "$ZSH" ]] \
|
||||||
|| [[ ! -t 1 ]] \
|
|| [[ ! -t 1 ]] \
|
||||||
|| ! command git --version 2>&1 >/dev/null; then
|
|| ! command git --version 2>&1 >/dev/null
|
||||||
|
|| (builtin cd -q "$ZSH"; ! command git rev-parse --is-inside-work-tree &>/dev/null); then
|
||||||
unset update_mode
|
unset update_mode
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue