mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-18 03:40:08 +00:00
fix(update): don't error on upgrade no-op (#9685)
* Don't error on upgrade no-op No error code is required for a non failure scenario. * Manually check whether changes were pulled in `omz update` Co-authored-by: Marc Cornellà <hello@mcornella.com>
This commit is contained in:
parent
9a9f383192
commit
6fbad5bf72
3 changed files with 5 additions and 6 deletions
|
@ -401,13 +401,14 @@ function _omz::theme::use {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _omz::update {
|
function _omz::update {
|
||||||
|
local last_commit=$(cd "$ZSH"; git rev-parse HEAD)
|
||||||
|
|
||||||
# Run update script
|
# Run update script
|
||||||
if [[ "$1" != --unattended ]]; then
|
if [[ "$1" != --unattended ]]; then
|
||||||
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
|
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
|
||||||
else
|
else
|
||||||
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh"
|
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh"
|
||||||
fi
|
fi
|
||||||
local ret=$?
|
|
||||||
|
|
||||||
# Update last updated file
|
# Update last updated file
|
||||||
zmodload zsh/datetime
|
zmodload zsh/datetime
|
||||||
|
@ -415,8 +416,8 @@ function _omz::update {
|
||||||
# Remove update lock if it exists
|
# Remove update lock if it exists
|
||||||
command rm -rf "$ZSH/log/update.lock"
|
command rm -rf "$ZSH/log/update.lock"
|
||||||
|
|
||||||
# Restart the zsh session
|
# Restart the zsh session if there were changes
|
||||||
if [[ $ret -eq 0 && "$1" != --unattended ]]; then
|
if [[ "$1" != --unattended && "$(cd "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
|
||||||
# Old zsh versions don't have ZSH_ARGZERO
|
# Old zsh versions don't have ZSH_ARGZERO
|
||||||
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
|
||||||
# Check whether to run a login shell
|
# Check whether to run a login shell
|
||||||
|
|
|
@ -24,8 +24,7 @@ function update_last_updated_file() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_ohmyzsh() {
|
function update_ohmyzsh() {
|
||||||
ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
|
if ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive; then
|
||||||
if [[ "$?" = (0|80) ]]; then
|
|
||||||
update_last_updated_file
|
update_last_updated_file
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,6 @@ if git pull --rebase --stat origin master; then
|
||||||
# Check if it was really updated or not
|
# Check if it was really updated or not
|
||||||
if [[ "$(git rev-parse HEAD)" = "$last_commit" ]]; then
|
if [[ "$(git rev-parse HEAD)" = "$last_commit" ]]; then
|
||||||
message="Oh My Zsh is already at the latest version."
|
message="Oh My Zsh is already at the latest version."
|
||||||
ret=80 # non-zero exit code to indicate no changes pulled
|
|
||||||
else
|
else
|
||||||
message="Hooray! Oh My Zsh has been updated!"
|
message="Hooray! Oh My Zsh has been updated!"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue