mirror of
https://github.com/neovim/neovim.git
synced 2025-12-12 09:32:39 +00:00
fix(pack)!: ensure plugin is fully absent if not fully installed
Problem: Currently it is possible to have plugin in a "partial install" state when `git clone` was successfull but `git checkout` was not. This was done to not checkout default branch by default in these situations (for security reasons). The problem is that it adds complexity when both dealing with lockfile (plugin's `rev` might be `nil`) and in how `src` and `version` are treated (wrong `src` - no plugin on disk; wrong `version` - "partial" plugin on disk). Solution: Treat plugin as "installed" if both `git clone` and `git checkout` are successful, while ensuring that not installed plugins are not on disk and in lockfile. This also means that if in 'init.lua' there is a `vim.pack.add()` with bad `version`, for first install there will be an informative error about it BUT next session will also try to install it. The solution is the same - adjust `version` beforehand.
This commit is contained in:
@@ -575,10 +575,9 @@ describe('vim.pack', function()
|
||||
|
||||
local pluginerr_hash = git_get_hash('main', 'pluginerr')
|
||||
local ref_lockfile = {
|
||||
-- Should be no entry for `repo_not_exist`
|
||||
-- Should be no entry for `repo_not_exist` and `basic` as they did not
|
||||
-- fully install
|
||||
plugins = {
|
||||
-- No `rev` because there was no relevant checkout
|
||||
basic = { src = repos_src.basic, version = "'not-exist'" },
|
||||
-- Error during sourcing 'plugin/' should not affect lockfile
|
||||
pluginerr = { rev = pluginerr_hash, src = repos_src.pluginerr, version = "'main'" },
|
||||
},
|
||||
@@ -605,14 +604,12 @@ describe('vim.pack', function()
|
||||
eq(false, vim.tbl_contains(rtp, after_dir))
|
||||
end)
|
||||
|
||||
it('does not checkout on bad `version`', function()
|
||||
it('does not install on bad `version`', function()
|
||||
local err = pcall_err(exec_lua, function()
|
||||
vim.pack.add({ { src = repos_src.basic, version = 'not-exist' } })
|
||||
end)
|
||||
matches('`not%-exist` is not a branch/tag/commit', err)
|
||||
local plug_path = pack_get_plug_path('basic')
|
||||
local entries = vim.iter(vim.fs.dir(plug_path)):totable()
|
||||
eq({ { '.git', 'directory' } }, entries)
|
||||
eq(false, pack_exists('basic'))
|
||||
end)
|
||||
|
||||
it('allows changing `src` of installed plugin', function()
|
||||
|
||||
Reference in New Issue
Block a user