*side,*install,*autoload: Significant cleanup via -zplg-store-ices

This commit is contained in:
Sebastian Gniazdowski 2017-12-09 17:25:59 +01:00
parent 87b0a52265
commit 573febbc49
4 changed files with 41 additions and 31 deletions

View file

@ -1,5 +1,7 @@
all: test
alltest: test testB testC testD
test:
make plugin svn curl

View file

@ -1244,16 +1244,8 @@ ZPLGM[EXTENDED_GLOB]=""
[[ ${+ice[make]} = 1 && ${ice[make]} != "!"* ]] && command make -C "$local_dir" ${(@s; ;)${ice[make]}}
}
# Record new ICE modifiers used
( builtin cd "$local_dir" || return 1
command mkdir -p ._zplugin
for key in proto from as bpick mv cp atclone atpull ver; do
print -r -- "${ice[$key]}" >! "._zplugin/$key"
done
# Optional file - create file for make ICE mod
(( ${+ice[make]} )) && print -r -- "${ice[make]}" >! "._zplugin/make" || command rm -f "._zplugin/make"
(( ${+ice[pick]} )) && print -r -- "${ice[pick]}" >! "._zplugin/pick" || command rm -f "._zplugin/pick"
)
# Store ices at update of plugin
-zplg-store-ices "$local_dir/._zplugin" ice "" "" "" ""
fi
return 0

View file

@ -130,14 +130,8 @@ builtin source ${ZPLGM[BIN_DIR]}"/zplugin-side.zsh"
fi
if [[ "$3" != "-u" ]]; then
command mkdir -p "$local_path/._zplugin"
local key
for key in proto from as bpick mv cp atclone atpull ver; do
print -r -- "${ZPLG_ICE[$key]}" >! "$local_path/._zplugin/$key"
done
# Optional file - create file for make ICE mod
(( ${+ZPLG_ICE[make]} )) && print -r -- "${ZPLG_ICE[make]}" >! "$local_path/._zplugin/make" || command rm -f "$local_path/._zplugin/make"
(( ${+ZPLG_ICE[pick]} )) && print -r -- "${ZPLG_ICE[pick]}" >! "$local_path/._zplugin/pick" || command rm -f "$local_path/._zplugin/pick"
# Store ices at clone of a plugin
-zplg-store-ices "$local_path/._zplugin" ZPLG_ICE "" "" "" ""
[[ ${+ZPLG_ICE[make]} = 1 && ${ZPLG_ICE[make]} = "!"* ]] && { command make -C "$local_path" ${(@s; ;)${ZPLG_ICE[make]#\!}}; }
( (( ${+ZPLG_ICE[atclone]} )) && { builtin cd "$local_path" && eval "${ZPLG_ICE[atclone]}"; }; )
@ -419,22 +413,15 @@ builtin source ${ZPLGM[BIN_DIR]}"/zplugin-side.zsh"
fi
(( retval == 1 )) && { command rmdir "$local_dir" 2>/dev/null; return $retval; }
(( retval == 2 )) && { return 0; }
if [[ "$local_dir${ZPLG_ICE[svn]+/$filename}" != "${ZPLGM[SNIPPETS_DIR]}" ]]; then
local pfx="$local_dir${ZPLG_ICE[svn]+/$filename}/._zplugin" key
(( ${+ZPLG_ICE[svn]} == 0 )) && pfx+="_$filename"
command mkdir -p "$pfx"
print -r -- "$save_url" >! "$pfx/url"
print -r -- "${+ZPLG_ICE[svn]}" >! "$pfx/mode"
for key in proto from as bpick mv cp atclone atpull ver; do
print -r -- "${ZPLG_ICE[$key]}" >! "$pfx/$key"
done
# Optional file - create file for make ICE mod
(( ${+ZPLG_ICE[make]} )) && print -r -- "${ZPLG_ICE[make]}" >! "$pfx/make" || command rm -f "$pfx/make"
(( ${+ZPLG_ICE[pick]} )) && print -r -- "${ZPLG_ICE[pick]}" >! "$pfx/pick" || command rm -f "$pfx/pick"
# Store ices at "clone" and update of snippet, SVN and single-file
local pfx="$local_dir${ZPLG_ICE[svn]+/$filename}/._zplugin${ZPLG_ICE[svn]-_$filename}"
-zplg-store-ices "$pfx" ZPLG_ICE "" "" "$save_url" "${+ZPLG_ICE[svn]}"
fi
(( retval == 2 )) && { return 0; }
if [[ -n "${ZPLG_ICE[mv]}" ]]; then
local from="${ZPLG_ICE[mv]%%[[:space:]]#->*}" to="${ZPLG_ICE[mv]##*->[[:space:]]#}"
local -a afr

View file

@ -123,7 +123,7 @@
REPLY="${ZPLGM[col-uname]}%${ZPLGM[col-rst]}${ZPLGM[col-pname]}${plugin}${ZPLGM[col-rst]}"
} || REPLY="${ZPLGM[col-uname]}${user}${ZPLGM[col-rst]}/${ZPLGM[col-pname]}${plugin}${ZPLGM[col-rst]}"
} # }}}
# FUNCTION: -zplg-two-paths()
# FUNCTION: -zplg-two-paths {{{
# Obtains a snippet URL without specification if it is an SVN URL (points to
# directory) or regular URL (points to file), returns 2 possible paths for
# further examination
@ -155,3 +155,32 @@
reply=( "$local_dirA/$filenameA" "$local_dirB" "$filenameB" )
}
# }}}
# FUNCTION: -zplg-store-ices {{{
# Saves ice mods in given hash onto disk.
#
# $1 - directory where to create / delete files
# $2 - name of hash that holds values
# $3 - additional keys of hash to store, space separated
# $4 - additional keys of hash to store, empty-meaningful ices, space separated
-zplg-store-ices() {
local __pfx="$1" __ice_var="$2" __add_ices="$3" __add_ices2="$4" url="$5" mode="$6"
command mkdir -p "$__pfx"
local __key __var_name
for __key in proto from as bpick mv cp atclone atpull ver ${(@s: :)__add_ices}; do
__var_name="${__ice_var}[$__key]"
print -r -- "${(P)__var_name}" >! "$__pfx"/$__key
done
# Ices that even empty mean something
for __key in make pick ${(@s: :)__add_ices2}; do
__var_name="${__ice_var}[$__key]"
(( ${(P)+__var_name} )) && print -r -- "${(P)__var_name}" >! "$__pfx"/$__key || command rm -f "$__pfx"/$__key
done
for __key in url mode; do
[[ -n "${(P)__key}" ]] && print -r -- "${(P)__key}" >! "$__pfx"/$__key
done
}
# }}}