Skip to content

Commit

Permalink
Fix multiple issues with ANTIGEN_CACHE configuration (#588)
Browse files Browse the repository at this point in the history
* Autoconfigure checkfiles
* Fix arguments passed to zcompile
* Fix ANTIGEN_CACHE config not handling false value
* Allow to overwrite ANTIGEN_RSRC
  • Loading branch information
desyncr authored Nov 16, 2017
1 parent 1d212d1 commit 9684d0c
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 21 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ env:
- USE_CONTAINER=docker
matrix:
include:
- os: osx
language: generic
env:
- USE_CONTAINER=no
- os: linux
env: ZSH_VERSION=zsh-5.3.1
- os: linux
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.2.1
develop
28 changes: 19 additions & 9 deletions bin/antigen.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ zmodload zsh/parameter

if [[ $ANTIGEN_CACHE != false ]]; then
ANTIGEN_CACHE="${ANTIGEN_CACHE:-${ADOTDIR:-$HOME/.antigen}/init.zsh}"
ANTIGEN_RSRC="${ADOTDIR:-$HOME/.antigen}/.resources"
ANTIGEN_RSRC="${ANTIGEN_RSRC:-${ADOTDIR:-$HOME/.antigen}/.resources}"

if [[ $ANTIGEN_AUTO_CONFIG != false && -f $ANTIGEN_RSRC ]]; then
ANTIGEN_CHECK_FILES=$(cat $ANTIGEN_RSRC 2> /dev/null)
Expand Down Expand Up @@ -1360,7 +1360,7 @@ antigen-use () {
fi
}
antigen-version () {
local version="v2.2.1"
local version="develop"
local extensions revision=""
if [[ -d $_ANTIGEN_INSTALL_DIR/.git ]]; then
revision=" ($(git --git-dir=$_ANTIGEN_INSTALL_DIR/.git rev-parse --short '@'))"
Expand Down Expand Up @@ -1782,7 +1782,7 @@ typeset -g _ZCACHE_CAPTURE_PREFIX
cat > $ANTIGEN_CACHE <<EOC
#-- START ZCACHE GENERATED FILE
#-- GENERATED: $(date)
#-- ANTIGEN v2.2.1
#-- ANTIGEN develop
$(functions -- _antigen)
antigen () {
local MATCH MBEGIN MEND
Expand All @@ -1806,17 +1806,20 @@ ${(j::)_sources}
#--- BUNDLES END
typeset -gaU _ANTIGEN_BUNDLE_RECORD; _ANTIGEN_BUNDLE_RECORD=($(print ${(qq)_ANTIGEN_BUNDLE_RECORD}))
typeset -g _ANTIGEN_CACHE_LOADED; _ANTIGEN_CACHE_LOADED=true
typeset -g ANTIGEN_CACHE_VERSION; ANTIGEN_CACHE_VERSION='v2.2.1'
typeset -g ANTIGEN_CACHE_VERSION; ANTIGEN_CACHE_VERSION='develop'
#-- END ZCACHE GENERATED FILE
EOC

{ zcompile "$ANTIGEN_CACHE" } &!

# Compile config files, if any
LOG "CHECK_FILES $ANTIGEN_CHECK_FILES"
[[ $ANTIGEN_AUTO_CONFIG == true && -n $ANTIGEN_CHECK_FILES ]] && {
echo "$ANTIGEN_CHECK_FILES" >! "$ANTIGEN_RSRC"
zcompile "$ANTIGEN_CHECK_FILES"
echo ${(j:\n:)ANTIGEN_CHECK_FILES} >! "$ANTIGEN_RSRC"
for rsrc in $ANTIGEN_CHECK_FILES; do
zcompile $rsrc
done
} &!

return true
Expand Down Expand Up @@ -1846,6 +1849,9 @@ EOC
# Default cache path.
-antigen-set-default ANTIGEN_CACHE $ADOTDIR/init.zsh
-antigen-set-default ANTIGEN_RSRC $ADOTDIR/.resources
if [[ $ANTIGEN_CACHE == false ]]; then
return 1
fi

return 0
}
Expand All @@ -1857,14 +1863,18 @@ EOC
# Auto determine check_files
# There always should be 5 steps from original source as the correct way is to use
# `antigen` wrapper not `antigen-apply` directly and it's called by an extension.
if [[ $ANTIGEN_AUTO_CONFIG == true && -z "$ANTIGEN_CHECK_FILES" && $#funcfiletrace -ge 5 ]]; then
ANTIGEN_CHECK_FILES+=("${${funcfiletrace[5]%:*}##* }")
LOG "TRACE: ${funcfiletrace}"
if [[ $ANTIGEN_AUTO_CONFIG == true ]]; then
ANTIGEN_CHECK_FILES+=(~/.zshrc)
if [[ $#funcfiletrace -ge 6 ]]; then
ANTIGEN_CHECK_FILES+=("${${funcfiletrace[6]%:*}##* }")
fi
fi

# Generate and compile cache
-antigen-cache-generate
[[ -f "$ANTIGEN_CACHE" ]] && source "$ANTIGEN_CACHE";

unset _ZCACHE_BUNDLE_SOURCE _ZCACHE_CAPTURE_BUNDLE _ZCACHE_CAPTURE_FUNCTIONS

# Release all hooked functions
Expand Down
2 changes: 1 addition & 1 deletion src/boot.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ zmodload zsh/parameter

if [[ $ANTIGEN_CACHE != false ]]; then
ANTIGEN_CACHE="${ANTIGEN_CACHE:-${ADOTDIR:-$HOME/.antigen}/init.zsh}"
ANTIGEN_RSRC="${ADOTDIR:-$HOME/.antigen}/.resources"
ANTIGEN_RSRC="${ANTIGEN_RSRC:-${ADOTDIR:-$HOME/.antigen}/.resources}"

if [[ $ANTIGEN_AUTO_CONFIG != false && -f $ANTIGEN_RSRC ]]; then
ANTIGEN_CHECK_FILES=$(cat $ANTIGEN_RSRC 2> /dev/null)
Expand Down
20 changes: 15 additions & 5 deletions src/ext/cache.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ EOC
{ zcompile "$ANTIGEN_CACHE" } &!

# Compile config files, if any
LOG "CHECK_FILES $ANTIGEN_CHECK_FILES"
[[ $ANTIGEN_AUTO_CONFIG == true && -n $ANTIGEN_CHECK_FILES ]] && {
echo "$ANTIGEN_CHECK_FILES" >! "$ANTIGEN_RSRC"
zcompile "$ANTIGEN_CHECK_FILES"
echo ${(j:\n:)ANTIGEN_CHECK_FILES} >! "$ANTIGEN_RSRC"
for rsrc in $ANTIGEN_CHECK_FILES; do
zcompile $rsrc
done
} &!

return true
Expand Down Expand Up @@ -98,6 +101,9 @@ EOC
# Default cache path.
-antigen-set-default ANTIGEN_CACHE $ADOTDIR/init.zsh
-antigen-set-default ANTIGEN_RSRC $ADOTDIR/.resources
if [[ $ANTIGEN_CACHE == false ]]; then
return 1
fi

return 0
}
Expand All @@ -109,14 +115,18 @@ EOC
# Auto determine check_files
# There always should be 5 steps from original source as the correct way is to use
# `antigen` wrapper not `antigen-apply` directly and it's called by an extension.
if [[ $ANTIGEN_AUTO_CONFIG == true && -z "$ANTIGEN_CHECK_FILES" && $#funcfiletrace -ge 5 ]]; then
ANTIGEN_CHECK_FILES+=("${${funcfiletrace[5]%:*}##* }")
LOG "TRACE: ${funcfiletrace}"
if [[ $ANTIGEN_AUTO_CONFIG == true ]]; then
ANTIGEN_CHECK_FILES+=(~/.zshrc)
if [[ $#funcfiletrace -ge 6 ]]; then
ANTIGEN_CHECK_FILES+=("${${funcfiletrace[6]%:*}##* }")
fi
fi

# Generate and compile cache
-antigen-cache-generate
[[ -f "$ANTIGEN_CACHE" ]] && source "$ANTIGEN_CACHE";

unset _ZCACHE_BUNDLE_SOURCE _ZCACHE_CAPTURE_BUNDLE _ZCACHE_CAPTURE_FUNCTIONS

# Release all hooked functions
Expand Down
3 changes: 2 additions & 1 deletion tests/.zshenv
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export ADOTDIR=$(mktemp -du "/tmp/dot-antigen-tmp-XXXXX")

export ANTIGEN=${ANTIGEN:-"/antigen"}
export ANTIGEN_AUTO_CONFIG=false
export ANTIGEN_CACHE=false
# Commented out due to tests/cache.t
#export ANTIGEN_CACHE=false
export ANTIGEN_RSRC=$ADOTDIR/.resources
export _ANTIGEN_WARN_DUPLICATES=false
export _ANTIGEN_INTERACTIVE=true
Expand Down

0 comments on commit 9684d0c

Please sign in to comment.