diff options
| author | Marc Cornellà <marc@mcornella.com> | 2024-04-18 07:33:13 +0200 |
|---|---|---|
| committer | Marc Cornellà <marc@mcornella.com> | 2024-04-18 07:33:13 +0200 |
| commit | 56cfcb44e7ff730c10c5a00b58f38c33c984c52e (patch) | |
| tree | e6bb2677d21b183ea6e05cfb9a2286c6d0f3ee6d /lib/cli.zsh | |
| parent | c262ffbb68e6dfc30b619e6ce6bdbd00f27b8a71 (diff) | |
| download | zsh-56cfcb44e7ff730c10c5a00b58f38c33c984c52e.tar.gz zsh-56cfcb44e7ff730c10c5a00b58f38c33c984c52e.tar.bz2 zsh-56cfcb44e7ff730c10c5a00b58f38c33c984c52e.zip | |
fix(updater): abort update if `$ZSH` is not a git repository
Fixes #12298
Diffstat (limited to 'lib/cli.zsh')
| -rw-r--r-- | lib/cli.zsh | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/cli.zsh b/lib/cli.zsh index aa36a6ab5..4a8d4d127 100644 --- a/lib/cli.zsh +++ b/lib/cli.zsh @@ -773,7 +773,17 @@ function _omz::theme::use { } 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 zstyle -s ':omz:update' verbose verbose_mode || verbose_mode=default |
