Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(bugfix): zinit self-update uses current branch #173

Merged
merged 3 commits into from
Apr 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/zsdoc/zinit-autoload.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 14 additions & 16 deletions zinit-autoload.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -711,14 +711,16 @@ ZINIT[EXTENDED_GLOB]=""
emulate -LR zsh
setopt extendedglob typesetsilent warncreateglobal

[[ $1 = -q ]] && +zinit-message "{info2}Updating Zinit{…}{rst}"
[[ $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)
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 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)"} )
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line removed --no-pager option, so #177 problem reoccurred. Can this be reverted?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there is a nother bug where log output should be on a newline. Preparing PR

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still it seems that there is no --no-pager in zinit self-update command. When it will be added?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yous,

Please open a new issue instead of commenting on a two year old PR.

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:]]#)#\)/}" )
Expand All @@ -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
Expand All @@ -740,21 +743,16 @@ ZINIT[EXTENDED_GLOB]=""
}
)
if [[ $1 != -q ]] {
+zinit-message "Compiling Zinit (zcompile){…}"
+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
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{}"
[[ $1 != -q ]] && +zinit-message -n "{pre}[self-update]{msg2} Reloading Zinit for the current session{msg2}"
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 ) {
Expand Down