From 23c47e197396daef778bf81f69ad59b3ae8452f6 Mon Sep 17 00:00:00 2001 From: Vladislav Doster Date: Mon, 11 Apr 2022 04:57:18 -0500 Subject: [PATCH 1/3] bugfix: zinit self-update respects the current branch Fix bug in Zinit `self-update` command that used the `main` branch instead of using current branch. Signed-off-by: Vladislav Doster --- doc/zsdoc/zinit-autoload.zsh.adoc | 2 +- zinit-autoload.zsh | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/doc/zsdoc/zinit-autoload.zsh.adoc b/doc/zsdoc/zinit-autoload.zsh.adoc index e6a62148a..fb7adca06 100644 --- a/doc/zsdoc/zinit-autoload.zsh.adoc +++ b/doc/zsdoc/zinit-autoload.zsh.adoc @@ -1068,7 +1068,7 @@ ____ User-action entry point. ____ -Has 45 line(s). Calls functions: +Has 42 line(s). Calls functions: .zinit-self-update |-- zinit.zsh/+zinit-message diff --git a/zinit-autoload.zsh b/zinit-autoload.zsh index 98062d5b2..eb2666ca7 100644 --- a/zinit-autoload.zsh +++ b/zinit-autoload.zsh @@ -714,11 +714,13 @@ ZINIT[EXTENDED_GLOB]="" [[ $1 = -q ]] && +zinit-message "{info2}Updating Zinit{…}{rst}" local nl=$'\n' escape=$'\x1b[' + local current_branch=$(builtin pushd $ZINIT[BIN_DIR] > /dev/null && git branch --show-current && popd > /dev/null) local -a lines - ( builtin cd -q "$ZINIT[BIN_DIR]" && \ - command git checkout main &>/dev/null && \ - command git fetch --quiet && \ - lines=( ${(f)"$(command git --no-pager log --color --date=short --pretty=format:'%Cgreen%cd %h %Creset%s %Cred%d%Creset || %b' ..FETCH_HEAD)"} ) + ( + builtin cd -q "$ZINIT[BIN_DIR]" \ + && +zinit-message -n "{pre}[self-update]{msg2} fetching changes for {msg2}$current_branch$nl{cmd}" \ + && command git fetch --quiet \ + && lines=( ${(f)"$(command git log --color --date=short --pretty=format:'%Cgreen%cd %h %Creset%s %Cred%d%Creset || %b' ..FETCH_HEAD)"} ) if (( ${#lines} > 0 )); then # Remove the (origin/main ...) segments, to expect only tags to appear lines=( "${(S)lines[@]//\(([,[:blank:]]#(origin|HEAD|master|main)[^a-zA-Z]##(HEAD|origin|master|main)[,[:blank:]]#)#\)/}" ) @@ -727,8 +729,9 @@ ZINIT[EXTENDED_GLOB]="" # If there's no ref-name, 2 consecutive spaces occur - fix this lines=( "${lines[@]/(#b)[[:space:]]#\|\|[[:space:]]#(*)(#e)/|| ${match[1]}}" ) lines=( "${lines[@]/(#b)$escape([0-9]##)m[[:space:]]##${escape}m/$escape${match[1]}m${escape}m}" ) - # Replace what follows "|| ..." with the same thing but with no newlines, - # and also only first 10 words (the (w)-flag enables word-indexing) + # Replace what follows "|| ..." with the same thing but with no + # newlines, and also only first 10 words (the (w)-flag enables + # word-indexing) lines=( "${lines[@]/(#b)[[:blank:]]#\|\|(*)(#e)/| ${${match[1]//$nl/ }[(w)1,(w)10]}}" ) builtin print -rl -- "${lines[@]}" | .zinit-pager builtin print @@ -744,17 +747,12 @@ ZINIT[EXTENDED_GLOB]="" } command rm -f $ZINIT[BIN_DIR]/*.zwc(DN) zcompile -U $ZINIT[BIN_DIR]/zinit.zsh - zcompile -U $ZINIT[BIN_DIR]/zinit-side.zsh - zcompile -U $ZINIT[BIN_DIR]/zinit-install.zsh - zcompile -U $ZINIT[BIN_DIR]/zinit-autoload.zsh - zcompile -U $ZINIT[BIN_DIR]/zinit-additional.zsh + zcompile -U $ZINIT[BIN_DIR]/zinit-{'side','install','autoload','additional'}.zsh zcompile -U $ZINIT[BIN_DIR]/share/git-process-output.zsh # Load for the current session [[ $1 != -q ]] && +zinit-message "Reloading Zinit for the current session{…}" source $ZINIT[BIN_DIR]/zinit.zsh - source $ZINIT[BIN_DIR]/zinit-side.zsh - source $ZINIT[BIN_DIR]/zinit-install.zsh - source $ZINIT[BIN_DIR]/zinit-autoload.zsh + zcompile -U $ZINIT[BIN_DIR]/zinit-{'side','install','autoload'}.zsh # Read and remember the new modification timestamps local file for file ( "" -side -install -autoload ) { From 047320a9234be4de8299ff4796e28e2363e77984 Mon Sep 17 00:00:00 2001 From: Vladislav Doster Date: Mon, 11 Apr 2022 18:27:09 -0500 Subject: [PATCH 2/3] feat: update output messaging to be more informative Signed-off-by: Vladislav Doster --- zinit-autoload.zsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/zinit-autoload.zsh b/zinit-autoload.zsh index eb2666ca7..22a00cec8 100644 --- a/zinit-autoload.zsh +++ b/zinit-autoload.zsh @@ -711,14 +711,14 @@ ZINIT[EXTENDED_GLOB]="" emulate -LR zsh setopt extendedglob typesetsilent warncreateglobal - [[ $1 = -q ]] && +zinit-message "{info2}Updating Zinit{…}{rst}" + [[ $1 = -q ]] && +zinit-message -n "{info2}[self-update]{info2}{msg2} Updating Zinit repository{msg2}" \ local nl=$'\n' escape=$'\x1b[' local current_branch=$(builtin pushd $ZINIT[BIN_DIR] > /dev/null && git branch --show-current && popd > /dev/null) local -a lines ( builtin cd -q "$ZINIT[BIN_DIR]" \ - && +zinit-message -n "{pre}[self-update]{msg2} fetching changes for {msg2}$current_branch$nl{cmd}" \ + && +zinit-message -n "{pre}[self-update]{msg2} fetching latest changes from {msg2}$current_branch$nl{cmd}" \ && command git fetch --quiet \ && lines=( ${(f)"$(command git log --color --date=short --pretty=format:'%Cgreen%cd %h %Creset%s %Cred%d%Creset || %b' ..FETCH_HEAD)"} ) if (( ${#lines} > 0 )); then @@ -743,14 +743,14 @@ ZINIT[EXTENDED_GLOB]="" } ) if [[ $1 != -q ]] { - +zinit-message "Compiling Zinit (zcompile){…}" + +zinit-message -n "{pre}[self-update]{msg2} compiling zinit (zinit){msg2}" } command rm -f $ZINIT[BIN_DIR]/*.zwc(DN) zcompile -U $ZINIT[BIN_DIR]/zinit.zsh zcompile -U $ZINIT[BIN_DIR]/zinit-{'side','install','autoload','additional'}.zsh zcompile -U $ZINIT[BIN_DIR]/share/git-process-output.zsh # Load for the current session - [[ $1 != -q ]] && +zinit-message "Reloading Zinit for the current session{…}" + [[ $1 != -q ]] && +zinit-message -n "{pre}[self-update]{msg2} Reloading Zinit for the current session{msg2}" source $ZINIT[BIN_DIR]/zinit.zsh zcompile -U $ZINIT[BIN_DIR]/zinit-{'side','install','autoload'}.zsh # Read and remember the new modification timestamps From eab948cdd0ea7aef309b29f9318ba58e11519e3d Mon Sep 17 00:00:00 2001 From: Vladislav Doster Date: Tue, 12 Apr 2022 13:12:58 -0500 Subject: [PATCH 3/3] maint: make logging style/colors consistent Signed-off-by: Vladislav Doster --- zinit-autoload.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zinit-autoload.zsh b/zinit-autoload.zsh index 22a00cec8..34f46c241 100644 --- a/zinit-autoload.zsh +++ b/zinit-autoload.zsh @@ -711,7 +711,7 @@ ZINIT[EXTENDED_GLOB]="" emulate -LR zsh setopt extendedglob typesetsilent warncreateglobal - [[ $1 = -q ]] && +zinit-message -n "{info2}[self-update]{info2}{msg2} Updating Zinit repository{msg2}" \ + [[ $1 = -q ]] && +zinit-message -n "{pre}[self-update]{msg2} Updating Zinit repository{msg2}" \ local nl=$'\n' escape=$'\x1b[' local current_branch=$(builtin pushd $ZINIT[BIN_DIR] > /dev/null && git branch --show-current && popd > /dev/null) @@ -743,7 +743,7 @@ ZINIT[EXTENDED_GLOB]="" } ) if [[ $1 != -q ]] { - +zinit-message -n "{pre}[self-update]{msg2} compiling zinit (zinit){msg2}" + +zinit-message -n "{pre}[self-update]{msg2} compiling zinit via {msg2}zcompile{cmd}" } command rm -f $ZINIT[BIN_DIR]/*.zwc(DN) zcompile -U $ZINIT[BIN_DIR]/zinit.zsh