1
0
Fork 0
mirror of synced 2024-11-22 15:25:34 -05:00

Fix getting HEAD remote branch in update.zsh.erb

instead of getting just the current local branch.
This commit is contained in:
Eric Nielsen 2021-02-17 17:51:22 -05:00
parent 36aa1b3fe9
commit 12dab4e893
No known key found for this signature in database
GPG key ID: 47D1DBFA0765A1FB
3 changed files with 29 additions and 22 deletions

View file

@ -7,7 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
_No unreleased changes._
### Fixed
- Correctly get the repository's default branch. The related change in version
1.4.0 actually broke updating the modules, as new changes stopped being
fetched.
## [1.4.0] - 2021-01-07

View file

@ -19,15 +19,18 @@ 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"
return 0
fi
elif [[ -z ${REV} ]]; then
# Get HEAD remote branch
if ! ERR=$(command git remote set-head origin -a 2>&1); then
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git remote set-head%f"$'\n'${(F):- ${(f)^ERR}}
return 1
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}}
@ -53,12 +56,11 @@ if [[ ${TYPE} == branch ]]; then
else
OUT="Updating to ${TYPE} ${REV}"
fi
if ERR=$(command git submodule update --init --recursive -q 2>&1); then
if (( PRINTLEVEL > 0 )); then
if [[ -n ${LOG} ]] OUT=${OUT}$'\n'${(F):- ${(f)^LOG}}
print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b ${OUT}"
fi
else
if ! ERR=$(command git submodule update --init --recursive -q 2>&1); then
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git submodule update%f"$'\n'${(F):- ${(f)^ERR}}
return 1
fi
if (( PRINTLEVEL > 0 )); then
if [[ -n ${LOG} ]] OUT=${OUT}$'\n'${(F):- ${(f)^LOG}}
print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b ${OUT}"
fi

View file

@ -319,7 +319,7 @@ _zimfw_compile() {
}
_zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2021-02-17 20:54:27 UTC, previous commit is e53614e)'
print -R 'zimfw version: '${_zversion}' (built at 2021-02-17 22:48:17 UTC, previous commit is 36aa1b3)'
print -R 'ZIM_HOME: '${ZIM_HOME}
print -R 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a)
@ -452,15 +452,18 @@ 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\"
return 0
fi
elif [[ -z \${REV} ]]; then
# Get HEAD remote branch
if ! ERR=\$(command git remote set-head origin -a 2>&1); then
print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git remote set-head%f\"$'\n'\${(F):- \${(f)^ERR}}
return 1
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}}
@ -486,15 +489,14 @@ if [[ \${TYPE} == branch ]]; then
else
OUT=\"Updating to \${TYPE} \${REV}\"
fi
if ERR=\$(command git submodule update --init --recursive -q 2>&1); then
if (( PRINTLEVEL > 0 )); then
if [[ -n \${LOG} ]] OUT=\${OUT}$'\n'\${(F):- \${(f)^LOG}}
print -PR \${CLEAR_LINE}\"%F{green})%f %B\${MODULE}:%b \${OUT}\"
fi
else
if ! ERR=\$(command git submodule update --init --recursive -q 2>&1); then
print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git submodule update%f\"$'\n'\${(F):- \${(f)^ERR}}
return 1
fi
if (( PRINTLEVEL > 0 )); then
if [[ -n \${LOG} ]] OUT=\${OUT}$'\n'\${(F):- \${(f)^LOG}}
print -PR \${CLEAR_LINE}\"%F{green})%f %B\${MODULE}:%b \${OUT}\"
fi
"
;;
esac