Use repository's default branch

instead of hardcoding the default to `master`, when no branch is
specified in `zmodule`.
Fixes #422
This commit is contained in:
Eric Nielsen 2021-01-02 19:09:52 -05:00
parent 153c547466
commit 3567694a0f
No known key found for this signature in database
GPG Key ID: 47D1DBFA0765A1FB
7 changed files with 19 additions and 18 deletions

View File

@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Show error when no parameter is provided to `-c|--cmd`. - Show error when no parameter is provided to `-c|--cmd`.
- Use repository's default branch instead of hardcoding the default to `master`.
## [1.3.2] - 2020-08-01 ## [1.3.2] - 2020-08-01

View File

@ -89,7 +89,7 @@ initialized in the same order they are defined.
Repository options: Repository options:
<strong>-b</strong>|<strong>--branch</strong> &lt;branch_name&gt; Use specified branch when installing and updating the module. <strong>-b</strong>|<strong>--branch</strong> &lt;branch_name&gt; Use specified branch when installing and updating the module.
Overrides the tag option. Default: <strong>master</strong>. Overrides the tag option. Default: the repository's default branch.
<strong>-t</strong>|<strong>--tag</strong> &lt;tag_name&gt; Use specified tag when installing and updating the module. <strong>-t</strong>|<strong>--tag</strong> &lt;tag_name&gt; Use specified tag when installing and updating the module.
Overrides the branch option. Overrides the branch option.
<strong>-z</strong>|<strong>--frozen</strong> Don't install or update the module. <strong>-z</strong>|<strong>--frozen</strong> Don't install or update the module.

View File

@ -10,7 +10,7 @@ The modules are initialized in the same order they are defined.
Repository options: Repository options:
%B-b%b|%B--branch%b <branch_name> Use specified branch when installing and updating the module. %B-b%b|%B--branch%b <branch_name> Use specified branch when installing and updating the module.
Overrides the tag option. Default: %Bmaster%b. Overrides the tag option. Default: the repository's default branch.
%B-t%b|%B--tag%b <tag_name> Use specified tag when installing and updating the module. %B-t%b|%B--tag%b <tag_name> Use specified tag when installing and updating the module.
Overrides the branch option. Overrides the branch option.
%B-z%b|%B--frozen%b Don't install or update the module. %B-z%b|%B--frozen%b Don't install or update the module.
@ -39,7 +39,7 @@ Initialization options:
fi fi
setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB
local zmodule=${1:t} zurl=${1} local zmodule=${1:t} zurl=${1}
local ztype=branch zrev=master local ztype=branch zrev
local -i zdisabled=0 zfrozen=0 local -i zdisabled=0 zfrozen=0
local -a zfpaths zfunctions zcmds local -a zfpaths zfunctions zcmds
local zarg zdir local zarg zdir
@ -121,7 +121,7 @@ Initialization options:
done done
if (( _zprepare_zargs )); then if (( _zprepare_zargs )); then
if (( ! zfrozen )); then if (( ! zfrozen )); then
_zmodules_zargs+=(${zmodule} ${zdir} ${zurl} ${ztype} ${zrev} ${_zprintlevel}) _zmodules_zargs+=(${zmodule} ${zdir} ${zurl} ${ztype} "${zrev}" ${_zprintlevel})
fi fi
else else
if (( zdisabled )); then if (( zdisabled )); then

View File

@ -66,7 +66,7 @@ Options:
install|update) install|update)
_zimfw_source_zimrc 1 || return 1 _zimfw_source_zimrc 1 || return 1
autoload -Uz zargs && \ autoload -Uz zargs && \
zargs -n 9 -P 10 -- ${_zmodules_zargs} -- zsh -c ${ztool} ${1} && \ zargs -n 9 -P 10 -- "${_zmodules_zargs[@]}" -- zsh -c ${ztool} ${1} && \
_zimfw_print -PR "<%= done %>Done with ${1}. Restart your terminal for any changes to take effect." || return 1 _zimfw_print -PR "<%= done %>Done with ${1}. Restart your terminal for any changes to take effect." || return 1
(( _zprintlevel-- )) (( _zprintlevel-- ))
_zimfw_source_zimrc && _zimfw_build && _zimfw_compile _zimfw_source_zimrc && _zimfw_build && _zimfw_compile

View File

@ -2,7 +2,7 @@
readonly MODULE=${1} readonly MODULE=${1}
readonly DIR=${2} readonly DIR=${2}
readonly URL=${3} readonly URL=${3}
readonly REV=${5} readonly BRANCH=${5:+-b ${5}}
readonly -i PRINTLEVEL=${6} readonly -i PRINTLEVEL=${6}
readonly CLEAR_LINE=$'\E[2K\r' readonly CLEAR_LINE=$'\E[2K\r'
if [[ -e ${DIR} ]]; then if [[ -e ${DIR} ]]; then
@ -10,7 +10,7 @@ if [[ -e ${DIR} ]]; then
return 0 return 0
fi fi
if (( PRINTLEVEL > 0 )) print -Rn ${CLEAR_LINE}"Installing ${MODULE}<%= ellipsis %>" if (( PRINTLEVEL > 0 )) print -Rn ${CLEAR_LINE}"Installing ${MODULE}<%= ellipsis %>"
if ERR=$(command git clone -b ${REV} -q --recursive ${URL} ${DIR} 2>&1); then if ERR=$(command git clone ${=BRANCH} -q --recursive ${URL} ${DIR} 2>&1); then
if (( PRINTLEVEL > 0 )) print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b Installed" if (( PRINTLEVEL > 0 )) print -PR ${CLEAR_LINE}"<%= okay %>%B${MODULE}:%b Installed"
else else
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git clone%f"$'\n'${(F):- ${(f)^ERR}} print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git clone%f"$'\n'${(F):- ${(f)^ERR}}

View File

@ -3,7 +3,7 @@ readonly MODULE=${1}
readonly DIR=${2} readonly DIR=${2}
readonly URL=${3} readonly URL=${3}
readonly TYPE=${4} readonly TYPE=${4}
readonly REV=${5} readonly REV=${5:=HEAD}
readonly -i PRINTLEVEL=${6} readonly -i PRINTLEVEL=${6}
readonly CLEAR_LINE=$'\E[2K\r' readonly CLEAR_LINE=$'\E[2K\r'
if (( PRINTLEVEL > 0 )) print -Rn ${CLEAR_LINE}"Updating ${MODULE}<%= ellipsis %>" if (( PRINTLEVEL > 0 )) print -Rn ${CLEAR_LINE}"Updating ${MODULE}<%= ellipsis %>"
@ -34,7 +34,7 @@ if [[ ${TYPE} == branch ]]; then
else else
LOG_REV=${REV} LOG_REV=${REV}
fi fi
LOG=$(command git log --graph --color --format='%C(yellow)%h%C(reset) %s %C(cyan)(%cr)%C(reset)' ..${LOG_REV} 2>/dev/null) LOG=$(command git log --graph --color --format='%C(yellow)%h%C(reset) %s %C(cyan)(%cr)%C(reset)' ..${LOG_REV} -- 2>/dev/null)
if ! ERR=$(command git checkout -q ${REV} -- 2>&1); then if ! ERR=$(command git checkout -q ${REV} -- 2>&1); then
print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git checkout%f"$'\n'${(F):- ${(f)^ERR}} print -u2 -PR ${CLEAR_LINE}"%F{red}<%= error %>%B${MODULE}:%b Error during git checkout%f"$'\n'${(F):- ${(f)^ERR}}
return 1 return 1

View File

@ -117,7 +117,7 @@ The modules are initialized in the same order they are defined.
Repository options: Repository options:
%B-b%b|%B--branch%b <branch_name> Use specified branch when installing and updating the module. %B-b%b|%B--branch%b <branch_name> Use specified branch when installing and updating the module.
Overrides the tag option. Default: %Bmaster%b. Overrides the tag option. Default: the repository's default branch.
%B-t%b|%B--tag%b <tag_name> Use specified tag when installing and updating the module. %B-t%b|%B--tag%b <tag_name> Use specified tag when installing and updating the module.
Overrides the branch option. Overrides the branch option.
%B-z%b|%B--frozen%b Don't install or update the module. %B-z%b|%B--frozen%b Don't install or update the module.
@ -146,7 +146,7 @@ Initialization options:
fi fi
setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB
local zmodule=${1:t} zurl=${1} local zmodule=${1:t} zurl=${1}
local ztype=branch zrev=master local ztype=branch zrev
local -i zdisabled=0 zfrozen=0 local -i zdisabled=0 zfrozen=0
local -a zfpaths zfunctions zcmds local -a zfpaths zfunctions zcmds
local zarg zdir local zarg zdir
@ -228,7 +228,7 @@ Initialization options:
done done
if (( _zprepare_zargs )); then if (( _zprepare_zargs )); then
if (( ! zfrozen )); then if (( ! zfrozen )); then
_zmodules_zargs+=(${zmodule} ${zdir} ${zurl} ${ztype} ${zrev} ${_zprintlevel}) _zmodules_zargs+=(${zmodule} ${zdir} ${zurl} ${ztype} "${zrev}" ${_zprintlevel})
fi fi
else else
if (( zdisabled )); then if (( zdisabled )); then
@ -319,7 +319,7 @@ _zimfw_compile() {
} }
_zimfw_info() { _zimfw_info() {
print -R 'zimfw version: '${_zversion}' (built at 2021-01-02 23:37:59 UTC, previous commit is dfbe535)' print -R 'zimfw version: '${_zversion}' (built at 2021-01-02 23:47:25 UTC, previous commit is 153c547)'
print -R 'ZIM_HOME: '${ZIM_HOME} print -R 'ZIM_HOME: '${ZIM_HOME}
print -R 'Zsh version: '${ZSH_VERSION} print -R 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a) print -R 'System info: '$(command uname -a)
@ -414,7 +414,7 @@ Options:
readonly MODULE=\${1} readonly MODULE=\${1}
readonly DIR=\${2} readonly DIR=\${2}
readonly URL=\${3} readonly URL=\${3}
readonly REV=\${5} readonly BRANCH=\${5:+-b \${5}}
readonly -i PRINTLEVEL=\${6} readonly -i PRINTLEVEL=\${6}
readonly CLEAR_LINE=$'\E[2K\r' readonly CLEAR_LINE=$'\E[2K\r'
if [[ -e \${DIR} ]]; then if [[ -e \${DIR} ]]; then
@ -422,7 +422,7 @@ if [[ -e \${DIR} ]]; then
return 0 return 0
fi fi
if (( PRINTLEVEL > 0 )) print -Rn \${CLEAR_LINE}\"Installing \${MODULE} ...\" if (( PRINTLEVEL > 0 )) print -Rn \${CLEAR_LINE}\"Installing \${MODULE} ...\"
if ERR=\$(command git clone -b \${REV} -q --recursive \${URL} \${DIR} 2>&1); then if ERR=\$(command git clone \${=BRANCH} -q --recursive \${URL} \${DIR} 2>&1); then
if (( PRINTLEVEL > 0 )) print -PR \${CLEAR_LINE}\"%F{green})%f %B\${MODULE}:%b Installed\" if (( PRINTLEVEL > 0 )) print -PR \${CLEAR_LINE}\"%F{green})%f %B\${MODULE}:%b Installed\"
else else
print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git clone%f\"$'\n'\${(F):- \${(f)^ERR}} print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git clone%f\"$'\n'\${(F):- \${(f)^ERR}}
@ -436,7 +436,7 @@ readonly MODULE=\${1}
readonly DIR=\${2} readonly DIR=\${2}
readonly URL=\${3} readonly URL=\${3}
readonly TYPE=\${4} readonly TYPE=\${4}
readonly REV=\${5} readonly REV=\${5:=HEAD}
readonly -i PRINTLEVEL=\${6} readonly -i PRINTLEVEL=\${6}
readonly CLEAR_LINE=$'\E[2K\r' readonly CLEAR_LINE=$'\E[2K\r'
if (( PRINTLEVEL > 0 )) print -Rn \${CLEAR_LINE}\"Updating \${MODULE} ...\" if (( PRINTLEVEL > 0 )) print -Rn \${CLEAR_LINE}\"Updating \${MODULE} ...\"
@ -467,7 +467,7 @@ if [[ \${TYPE} == branch ]]; then
else else
LOG_REV=\${REV} LOG_REV=\${REV}
fi fi
LOG=\$(command git log --graph --color --format='%C(yellow)%h%C(reset) %s %C(cyan)(%cr)%C(reset)' ..\${LOG_REV} 2>/dev/null) LOG=\$(command git log --graph --color --format='%C(yellow)%h%C(reset) %s %C(cyan)(%cr)%C(reset)' ..\${LOG_REV} -- 2>/dev/null)
if ! ERR=\$(command git checkout -q \${REV} -- 2>&1); then if ! ERR=\$(command git checkout -q \${REV} -- 2>&1); then
print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git checkout%f\"$'\n'\${(F):- \${(f)^ERR}} print -u2 -PR \${CLEAR_LINE}\"%F{red}x %B\${MODULE}:%b Error during git checkout%f\"$'\n'\${(F):- \${(f)^ERR}}
return 1 return 1
@ -511,7 +511,7 @@ fi
install|update) install|update)
_zimfw_source_zimrc 1 || return 1 _zimfw_source_zimrc 1 || return 1
autoload -Uz zargs && \ autoload -Uz zargs && \
zargs -n 9 -P 10 -- ${_zmodules_zargs} -- zsh -c ${ztool} ${1} && \ zargs -n 9 -P 10 -- "${_zmodules_zargs[@]}" -- zsh -c ${ztool} ${1} && \
_zimfw_print -PR "Done with ${1}. Restart your terminal for any changes to take effect." || return 1 _zimfw_print -PR "Done with ${1}. Restart your terminal for any changes to take effect." || return 1
(( _zprintlevel-- )) (( _zprintlevel-- ))
_zimfw_source_zimrc && _zimfw_build && _zimfw_compile _zimfw_source_zimrc && _zimfw_build && _zimfw_compile