mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-09-28 14:06:12 +02:00
fix(gh): preserve valid completion cache on failure
This commit is contained in:
@@ -15,9 +15,6 @@ This plugin does not add any aliases.
|
|||||||
This plugin caches the completion script and is automatically updated when the
|
This plugin caches the completion script and is automatically updated when the
|
||||||
plugin is loaded, which is usually when you start up a new terminal emulator.
|
plugin is loaded, which is usually when you start up a new terminal emulator.
|
||||||
|
|
||||||
The cache is stored at:
|
The completion script is stored at `$ZSH_CACHE_DIR/completions/_gh`. If an
|
||||||
|
update fails, the plugin keeps the last successfully generated completion
|
||||||
- `$ZSH/plugins/gh/_gh` completions script
|
script.
|
||||||
|
|
||||||
- `$ZSH_CACHE_DIR/gh_version` version of GitHub CLI, used to invalidate
|
|
||||||
the cache.
|
|
||||||
|
|||||||
@@ -13,6 +13,12 @@ fi
|
|||||||
|
|
||||||
zmodload -F zsh/files b:zf_mv
|
zmodload -F zsh/files b:zf_mv
|
||||||
() {
|
() {
|
||||||
local TMPPREFIX="$ZSH_CACHE_DIR/completions/_gh"
|
local completion_file="$ZSH_CACHE_DIR/completions/_gh"
|
||||||
zf_mv -f -- =( gh completion --shell zsh ) "$TMPPREFIX"
|
local completion_tmp="${completion_file}.$$.${RANDOM}"
|
||||||
|
|
||||||
|
if gh completion --shell zsh >| "$completion_tmp" && [[ -s "$completion_tmp" ]]; then
|
||||||
|
zf_mv -f -- "$completion_tmp" "$completion_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
command rm -f -- "$completion_tmp"
|
||||||
} &|
|
} &|
|
||||||
|
|||||||
Reference in New Issue
Block a user