Fix update.zsh.erb for renamed HEAD remote branch

We need to fetch all branches first to handle the scenario when the HEAD
remote branch was renamed. Recently repositories started changing their
HEAD branch names from master to main.
Fixes #424
This commit is contained in:
Eric Nielsen 2021-02-19 15:17:10 -05:00
parent ddfba96c88
commit 6d577d7f6a
No known key found for this signature in database
GPG Key ID: 47D1DBFA0765A1FB
4 changed files with 14 additions and 12 deletions

View File

@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
_No unreleased changes._
### Fixed
- "Not a valid ref: refs/remotes/origin/main" error when the repository's default
branch was renamed to main.
## [1.4.1] - 2021-02-17

View File

@ -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 ! ERR=$(command git fetch -pq origin 2>&1); then
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git fetch%f"$'\n'${(F):- ${(f)^ERR}}
return 1
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"
@ -32,10 +36,6 @@ elif [[ -z ${REV} ]]; then
fi
REV=${$(command git symbolic-ref --short refs/remotes/origin/HEAD)#origin/} || return 1
fi
if ! ERR=$(command git fetch -pq origin ${REV} 2>&1); then
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git fetch%f"$'\n'${(F):- ${(f)^ERR}}
return 1
fi
if [[ ${TYPE} == branch ]]; then
LOG_REV=${REV}@{u}
else

View File

@ -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.1"
@version = "1.4.2-SNAPSHOT"
@ellipsis = " ..."
@okay = "%F{green})%f "
@warn = "! "

View File

@ -319,7 +319,7 @@ _zimfw_compile() {
}
_zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2021-02-17 23:25:22 UTC, previous commit is 12dab4e)'
print -R 'zimfw version: '${_zversion}' (built at 2021-02-19 19:42:09 UTC, previous commit is ddfba96)'
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.1'
local -r _zversion='1.4.2-SNAPSHOT'
local -r zusage="Usage: %B${0}%b <action> [%B-q%b|%B-v%b]
Actions:
@ -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 ! ERR=\$(command git fetch -pq origin 2>&1); then
print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git fetch%f\"$'\n'\${(F):- \${(f)^ERR}}
return 1
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\"
@ -465,10 +469,6 @@ elif [[ -z \${REV} ]]; then
fi
REV=\${\$(command git symbolic-ref --short refs/remotes/origin/HEAD)#origin/} || return 1
fi
if ! ERR=\$(command git fetch -pq origin \${REV} 2>&1); then
print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git fetch%f\"$'\n'\${(F):- \${(f)^ERR}}
return 1
fi
if [[ \${TYPE} == branch ]]; then
LOG_REV=\${REV}@{u}
else