From 608a62b6e711284458828f73efddd1d503c1489e Mon Sep 17 00:00:00 2001 From: Romain Bossart Date: Thu, 13 Dec 2018 08:44:27 +0100 Subject: [PATCH] _brew | use git-index mtime for caching policy --- completions/zsh/_brew | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/completions/zsh/_brew b/completions/zsh/_brew index 6a29338db1..4db3878dae 100644 --- a/completions/zsh/_brew +++ b/completions/zsh/_brew @@ -39,8 +39,8 @@ __brew_formulae_or_ruby_files() { 'files:files:{_files -g *.rb}' } -# formulae completions are cached as long as homebrew does have new commits -__brew_formulae_caching_policy() { +# completions are cached as long as homebrew does have new commits +__brew_completion_caching_policy() { # rebuild cache if no cache file exists (anyway we cannot proceed further down) ! [[ -f "$1" ]] && return 0 # cache file modification date (seconds since epoch) @@ -52,7 +52,7 @@ __brew_formulae_caching_policy() { } __brew_formulae() { - zstyle ":completion:${curcontext}:" cache-policy __brew_formulae_caching_policy + zstyle ":completion:${curcontext}:" cache-policy __brew_completion_caching_policy local -a formulae local comp_cachename=brew_formulae if _cache_invalid $comp_cachename || ! _retrieve_cache $comp_cachename; then @@ -146,15 +146,8 @@ __brew_common_commands() { _describe -t common-commands 'common commands' commands } -# completions are cached for 24 hour -__brew_commands_caching_policy() { - local -a oldp - oldp=( "$1"(Nmh+24) ) - (( $#oldp )) -} - __brew_all_commands() { - zstyle ":completion:${curcontext}:" cache-policy __brew_commands_caching_policy + zstyle ":completion:${curcontext}:" cache-policy __brew_completion_caching_policy local -a commands local comp_cachename=brew_all_commands if _cache_invalid $comp_cachename || ! _retrieve_cache $comp_cachename; then