e8e37eedbc8cf5e446be11971769df7cc10faeb0

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

Message

feat(updater): save version prior to updating so `omz changelog` just works™

Fixes #9505

Diff

 1diff --git a/tools/changelog.sh b/tools/changelog.sh
 2index 4ce42e5a3745597dc83a7170ed9efd48173cd2f1..845b1d4b406ff46dca7dadeddb203e319996cc20 100755
 3--- a/tools/changelog.sh
 4+++ b/tools/changelog.sh
 5@@ -340,16 +340,23 @@ function display-release {
 6 
 7 function main {
 8   # $1 = until commit, $2 = since commit
 9-  # $3 = output format (--raw|--text|--md)
10   local until="$1" since="$2"
11+
12+  # $3 = output format (--text|--raw|--md)
13+  # --md:   uses markdown formatting
14+  # --raw:  outputs without style
15+  # --text: uses ANSI escape codes to style the output
16   local output=${${3:-"--text"}#--*}
17 
18   if [[ -z "$until" ]]; then
19     until=HEAD
20   fi
21 
22-  # If $since is not specified, look up first version tag before $until
23   if [[ -z "$since" ]]; then
24+    # If $since is not specified:
25+    # 1) try to find the version used before updating
26+    # 2) try to find the first version tag before $until
27+    since=$(command git config --get oh-my-zsh.lastVersion 2>/dev/null) || \
28     since=$(command git describe --abbrev=0 --tags "$until^" 2>/dev/null) || \
29     unset since
30   elif [[ "$since" = --all ]]; then
31diff --git a/tools/upgrade.sh b/tools/upgrade.sh
32index cfd42452715ef367fd2df800e64f974a2b28e164..4df7eb184e4bf8566e4f7ea4b20dbdc6a20109b6 100755
33--- a/tools/upgrade.sh
34+++ b/tools/upgrade.sh
35@@ -10,7 +10,7 @@ cd "$ZSH"
36 # and that terminal supports them.
37 
38 local -a RAINBOW
39-local RED GREEN YELLOW BLUE UNDER BOLD RESET
40+local RED GREEN YELLOW BLUE BOLD DIM UNDER RESET
41 
42 if [ -t 1 ]; then
43   RAINBOW=(
44@@ -28,6 +28,7 @@ if [ -t 1 ]; then
45   YELLOW=$(printf '\033[33m')
46   BLUE=$(printf '\033[34m')
47   BOLD=$(printf '\033[1m')
48+  DIM=$(printf '\033[2m')
49   UNDER=$(printf '\033[4m')
50   RESET=$(printf '\033[m')
51 fi
52@@ -69,6 +70,9 @@ if git pull --rebase --stat origin master; then
53   else
54     message="Hooray! Oh My Zsh has been updated!"
55 
56+    # Save the commit prior to updating
57+    git config oh-my-zsh.lastVersion "$last_commit"
58+
59     # Display changelog with less if available, otherwise just print it to the terminal
60     if [[ "$1" = --interactive ]]; then
61       if (( $+commands[less] )); then
62@@ -77,6 +81,8 @@ if git pull --rebase --stat origin master; then
63         "$ZSH/tools/changelog.sh" HEAD "$last_commit"
64       fi
65     fi
66+
67+    printf "${BLUE}%s \`${BOLD}%s${RESET}${BLUE}\`${RESET}\n" "You can see the changelog again with" "omz changelog"
68   fi
69 
70   printf '%s         %s__      %s           %s        %s       %s     %s__   %s\n' $RAINBOW $RESET