From 36aa1b3fe94bc79414a792f507f284be931504c2 Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Wed, 17 Feb 2021 15:55:38 -0500 Subject: [PATCH] Fix getting default branch in update.zsh.erb The regression was introduced in commit 3567694. I wrongly assumed that `git fetch -pq origin HEAD` would fetch from the remote default branch. Fixes #423 --- src/tools/update.zsh.erb | 6 +++++- src/zimfw.zsh.erb | 2 +- zimfw.zsh | 10 +++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/tools/update.zsh.erb b/src/tools/update.zsh.erb index fbd1a39..9d77957 100644 --- a/src/tools/update.zsh.erb +++ b/src/tools/update.zsh.erb @@ -3,7 +3,7 @@ readonly MODULE=${1} readonly DIR=${2} readonly URL=${3} readonly TYPE=${4:=branch} -readonly REV=${5:=HEAD} +REV=${5} readonly -i PRINTLEVEL=${6} readonly CLEAR_LINE=$'\E[2K\r' if (( PRINTLEVEL > 0 )) print -Rn ${CLEAR_LINE}"Updating ${MODULE}<%= ellipsis %>" @@ -19,6 +19,10 @@ if [[ ${URL} != $(command git config --get remote.origin.url) ]]; then print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b URL does not match. Expected ${URL}. Will not try to update.%f" return 1 fi +if [[ -z ${REV} ]]; then + # Get HEAD branch + REV=$(command git symbolic-ref --short HEAD) +fi if [[ ${TYPE} == tag ]]; then if [[ ${REV} == $(command git describe --tags --exact-match 2>/dev/null) ]]; then if (( PRINTLEVEL > 0 )) print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b Already up to date" diff --git a/src/zimfw.zsh.erb b/src/zimfw.zsh.erb index 760a7e7..07c3ae5 100644 --- a/src/zimfw.zsh.erb +++ b/src/zimfw.zsh.erb @@ -6,7 +6,7 @@ class Zim @home = "${ZDOTDIR:-${HOME}}" @min_zsh_version = "5.2" @startup_files_glob = ".z(shenv|profile|shrc|login|logout)" - @version = "1.4.0" + @version = "1.4.1-SNAPSHOT" @ellipsis = " ..." @okay = "%F{green})%f " @warn = "! " diff --git a/zimfw.zsh b/zimfw.zsh index fa71691..0d1c835 100644 --- a/zimfw.zsh +++ b/zimfw.zsh @@ -319,7 +319,7 @@ _zimfw_compile() { } _zimfw_info() { - print -R 'zimfw version: '${_zversion}' (built at 2021-01-07 18:39:43 UTC, previous commit is bcae8c0)' + print -R 'zimfw version: '${_zversion}' (built at 2021-02-17 20:54:27 UTC, previous commit is e53614e)' print -R 'ZIM_HOME: '${ZIM_HOME} print -R 'Zsh version: '${ZSH_VERSION} print -R 'System info: '$(command uname -a) @@ -366,7 +366,7 @@ _zimfw_upgrade() { } zimfw() { - local -r _zversion='1.4.0' + local -r _zversion='1.4.1-SNAPSHOT' local -r zusage="Usage: %B${0}%b [%B-q%b|%B-v%b] Actions: @@ -436,7 +436,7 @@ readonly MODULE=\${1} readonly DIR=\${2} readonly URL=\${3} readonly TYPE=\${4:=branch} -readonly REV=\${5:=HEAD} +REV=\${5} readonly -i PRINTLEVEL=\${6} readonly CLEAR_LINE=$'\E[2K\r' if (( PRINTLEVEL > 0 )) print -Rn \${CLEAR_LINE}\"Updating \${MODULE} ...\" @@ -452,6 +452,10 @@ if [[ \${URL} != \$(command git config --get remote.origin.url) ]]; then print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b URL does not match. Expected \${URL}. Will not try to update.%f\" return 1 fi +if [[ -z \${REV} ]]; then + # Get HEAD branch + REV=\$(command git symbolic-ref --short HEAD) +fi if [[ \${TYPE} == tag ]]; then if [[ \${REV} == \$(command git describe --tags --exact-match 2>/dev/null) ]]; then if (( PRINTLEVEL > 0 )) print -PR \${CLEAR_LINE}\"%F{green})%f %B\${MODULE}:%b Already up to date\"