Reinstall a damaged Neovim plugin instead of only stashing its changes
shellcheck / shellcheck (push) Failing after 15s
shellcheck / shellcheck (push) Failing after 15s
Stashing a plugin's mismatched files wasn't enough for LuaSnip: the interrupted update had also left new files git won't overwrite and a half-cloned submodule, so lazy.nvim still couldn't check out the new version, and said nothing. Move such a plugin to ~/.local/state/coredesktop/nvim-plugins/ instead, so Lazy! sync installs it afresh and any edits to it are kept. A plugin the earlier version of this step stashed is moved the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+31
-14
@@ -7,12 +7,13 @@ load test_helper
|
||||
|
||||
setup() {
|
||||
common_setup
|
||||
export XDG_DATA_HOME="$HOME/.local/share"
|
||||
export XDG_DATA_HOME="$HOME/.local/share" XDG_STATE_HOME="$HOME/.local/state"
|
||||
LAZY="$XDG_DATA_HOME/nvim/lazy"
|
||||
BACKUPS="$XDG_STATE_HOME/coredesktop/nvim-plugins"
|
||||
mkdir -p "$LAZY"
|
||||
export GIT_AUTHOR_NAME=test GIT_AUTHOR_EMAIL=test@example.com
|
||||
export GIT_COMMITTER_NAME=test GIT_COMMITTER_EMAIL=test@example.com
|
||||
stub nvim 'echo "nvim ran" >> "$BATS_TEST_TMPDIR/nvim.log"'
|
||||
stub nvim
|
||||
}
|
||||
|
||||
# plugin NAME: a plugin checkout with one committed file
|
||||
@@ -28,28 +29,44 @@ update_neovim() {
|
||||
run_update
|
||||
}
|
||||
|
||||
@test "a plugin with local changes is stashed so lazy.nvim can update it" {
|
||||
@test "a plugin whose files don't match its checkout is set aside to be installed again" {
|
||||
plugin LuaSnip
|
||||
echo changed > "$LAZY/LuaSnip/README.md"
|
||||
echo build output > "$LAZY/LuaSnip/untracked.so"
|
||||
mkdir "$LAZY/LuaSnip/data"
|
||||
echo leftover > "$LAZY/LuaSnip/data/new.md"
|
||||
|
||||
run update_neovim
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" == *"LuaSnip had local changes"* ]]
|
||||
[ -z "$(git -C "$LAZY/LuaSnip" ls-files -d -m)" ]
|
||||
[ "$(cat "$LAZY/LuaSnip/README.md")" = original ]
|
||||
# The changes can be got back, and untracked build output is left alone
|
||||
git -C "$LAZY/LuaSnip" stash list | grep -q "Stashed by CoreDesktop's update"
|
||||
[ -f "$LAZY/LuaSnip/untracked.so" ]
|
||||
grep -q "nvim ran" "$BATS_TEST_TMPDIR/nvim.log"
|
||||
[[ "$output" == *"LuaSnip's files didn't match its version"* ]]
|
||||
[ ! -e "$LAZY/LuaSnip" ]
|
||||
# The old copy, edits and all, is kept
|
||||
copies=("$BACKUPS"/LuaSnip-*)
|
||||
[ "${#copies[@]}" -eq 1 ]
|
||||
[ "$(cat "${copies[0]}/README.md")" = changed ]
|
||||
[ -f "${copies[0]}/data/new.md" ]
|
||||
called nvim --headless "+Lazy! sync" +qa
|
||||
}
|
||||
|
||||
@test "plugins without local changes are left as they are" {
|
||||
@test "a plugin an earlier update only stashed is set aside too" {
|
||||
plugin LuaSnip
|
||||
echo changed > "$LAZY/LuaSnip/README.md"
|
||||
git -C "$LAZY/LuaSnip" stash push -q -m "Stashed by CoreDesktop's update"
|
||||
|
||||
run update_neovim
|
||||
[ "$status" -eq 0 ]
|
||||
[ ! -e "$LAZY/LuaSnip" ]
|
||||
[ -d "$(echo "$BACKUPS"/LuaSnip-*)" ]
|
||||
}
|
||||
|
||||
@test "plugins that match their checkout are left as they are" {
|
||||
plugin lazy.nvim
|
||||
echo build output > "$LAZY/lazy.nvim/untracked.so"
|
||||
echo changed > "$LAZY/lazy.nvim/README.md"
|
||||
git -C "$LAZY/lazy.nvim" stash push -q -m "the user's own stash"
|
||||
|
||||
run update_neovim
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "$output" != *"local changes"* ]]
|
||||
[ -z "$(git -C "$LAZY/lazy.nvim" stash list)" ]
|
||||
[[ "$output" != *"didn't match"* ]]
|
||||
[ -f "$LAZY/lazy.nvim/untracked.so" ]
|
||||
[ ! -e "$BACKUPS" ]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user