5a888ff4ac58798ccdff0f32c4609fd153edc217

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

fix(updater): don't show changelog when running unattended update (#9495)

Fixes #9495

Diff

 1diff --git a/lib/cli.zsh b/lib/cli.zsh
 2index 38cdc449c742bc1c25d3c9aa0422620a3a08ae05..92d447a8e2c3c2dcd5d71017943a70423fddfce7 100644
 3--- a/lib/cli.zsh
 4+++ b/lib/cli.zsh
 5@@ -376,13 +376,19 @@ function _omz::theme::use {
 6 
 7 function _omz::update {
 8   # Run update script
 9-  env ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh"
10+  if [[ "$1" != --unattended ]]; then
11+    ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
12+  else
13+    ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh"
14+  fi
15   local ret=$?
16+
17   # Update last updated file
18   zmodload zsh/datetime
19   echo "LAST_EPOCH=$(( EPOCHSECONDS / 60 / 60 / 24 ))" >! "${ZSH_CACHE_DIR}/.zsh-update"
20   # Remove update lock if it exists
21   command rm -rf "$ZSH/log/update.lock"
22+
23   # Restart the zsh session
24   if [[ $ret -eq 0 && "$1" != --unattended ]]; then
25     # Check whether to run a login shell
26diff --git a/lib/functions.zsh b/lib/functions.zsh
27index b0582b32b62ccff176624fae2f8bc8376e2475be..0fc7580701615b216bef058067b29624e7358660 100644
28--- a/lib/functions.zsh
29+++ b/lib/functions.zsh
30@@ -14,7 +14,7 @@ function upgrade_oh_my_zsh() {
31   fi
32 
33   # Run update script
34-  env ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh"
35+  env ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
36   local ret=$?
37   # Update last updated file
38   zmodload zsh/datetime
39diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh
40index 17925af8b81efa7630006342ecf6546c734db8e2..d0ceba92d03e1a59839e0a448076c507e9e80c55 100644
41--- a/tools/check_for_upgrade.sh
42+++ b/tools/check_for_upgrade.sh
43@@ -24,7 +24,7 @@ function update_last_updated_file() {
44 }
45 
46 function update_ohmyzsh() {
47-  ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh"
48+  ZSH="$ZSH" zsh -f "$ZSH/tools/upgrade.sh" --interactive
49   update_last_updated_file
50 }
51 
52diff --git a/tools/upgrade.sh b/tools/upgrade.sh
53index 0e4c368bc8a7c1d077353c9a61171ae1e127841d..cfd42452715ef367fd2df800e64f974a2b28e164 100755
54--- a/tools/upgrade.sh
55+++ b/tools/upgrade.sh
56@@ -70,10 +70,12 @@ if git pull --rebase --stat origin master; then
57     message="Hooray! Oh My Zsh has been updated!"
58 
59     # Display changelog with less if available, otherwise just print it to the terminal
60-    if (( $+commands[less] )); then
61-      "$ZSH/tools/changelog.sh" HEAD "$last_commit" --text | command less -R
62-    else
63-      "$ZSH/tools/changelog.sh" HEAD "$last_commit"
64+    if [[ "$1" = --interactive ]]; then
65+      if (( $+commands[less] )); then
66+        "$ZSH/tools/changelog.sh" HEAD "$last_commit" --text | LESS= command less -R
67+      else
68+        "$ZSH/tools/changelog.sh" HEAD "$last_commit"
69+      fi
70     fi
71   fi
72