Cai Cooper <2406847+cagiti@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date
Message
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>
Diff
1diff --git a/lib/cli.zsh b/lib/cli.zsh
2index 3346d3973407378606897ff1792b4d8b1b63b0ff..38e2f72f816be47abc47a659023c93ff21374db8 100644
3--- a/lib/cli.zsh
4+++ b/lib/cli.zsh
5@@ -401,13 +401,14 @@ function _omz::theme::use {
6 }
7 8 function _omz::update {
9+ local last_commit=$(cd "$ZSH"; git rev-parse HEAD)
10+
11 # Run update script
12 if [[ "$1" != --unattended ]]; then
13 ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
14 else
15 ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh"
16 fi
17- local ret=$?
1819 # Update last updated file
20 zmodload zsh/datetime
21@@ -415,8 +416,8 @@ function _omz::update {
22 # Remove update lock if it exists
23 command rm -rf "$ZSH/log/update.lock"
2425- # Restart the zsh session
26- if [[ $ret -eq 0 && "$1" != --unattended ]]; then
27+ # Restart the zsh session if there were changes
28+ if [[ "$1" != --unattended && "$(cd "$ZSH"; git rev-parse HEAD)" != "$last_commit" ]]; then
29 # Old zsh versions don't have ZSH_ARGZERO
30 local zsh="${ZSH_ARGZERO:-${functrace[-1]%:*}}"
31 # Check whether to run a login shell
32diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
33index 88e521eea232a1f89cbf3726268285593ba7abaa..29a48b88033641c98aaf1378663b453a6610f27c 100644
34--- a/tools/check_for_upgrade.sh
35+++ b/tools/check_for_upgrade.sh
36@@ -24,8 +24,7 @@ function update_last_updated_file() {
37 }
3839 function update_ohmyzsh() {
40- ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
41- if [[ "$?" = (0|80) ]]; then
42+ if ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive; then
43 update_last_updated_file
44 fi
45 }
46diff --git a/tools/upgrade.sh b/tools/upgrade.sh
47index 4b97540d67985a295b64374daed9bd027dbb07c6..417e06fe882b950dcfe468e388cdfbec188cc377 100755
48--- a/tools/upgrade.sh
49+++ b/tools/upgrade.sh
50@@ -66,7 +66,6 @@ if git pull --rebase --stat origin master; then
51 # Check if it was really updated or not
52 if [[ "$(git rev-parse HEAD)" = "$last_commit" ]]; then
53 message="Oh My Zsh is already at the latest version."
54- ret=80 # non-zero exit code to indicate no changes pulled
55 else
56 message="Hooray! Oh My Zsh has been updated!"
57