mirror of
https://github.com/neovim/neovim.git
synced 2025-11-03 17:24:29 +00:00
fix(pack)!: do not trigger PackChanged[Pre] kind=update during install
Problem: `PackChanged[Pre]` events with `kind=update` are triggered both during plugin's initial installation and after already installed plugin was updated. It was a deliberate decision to allow writing only a single update hook to act as a dedicated "build" entry point (like execute `make` or `cargo build —release`). This mimics how other plugin managers have a single "build" command. This was a result of 'mini.deps' experience with the different approach: "update" hooks are not run during install. This proved to be confusing as it requires to write two hooks. But also the reason might be that 'mini.deps' names it "checkout" hook instead of "update". However, the `vim.pack` event approach makes it lower cost to handle separate "update" and "install" events. Something like `if ev.data.kind == 'install' or ev.data.kind == 'update' then` instead of two autocommands. Plus this makes clearer separation of events. Solution: do not trigger `PackChanged[Pre] kind=update` event during install.
This commit is contained in:
@@ -674,23 +674,13 @@ describe('vim.pack', function()
|
||||
local find_event = make_find_packchanged(log)
|
||||
local installpre_basic = find_event('Pre', 'install', 'basic', 'feat-branch', false)
|
||||
local installpre_defbranch = find_event('Pre', 'install', 'defbranch', nil, false)
|
||||
local updatepre_basic = find_event('Pre', 'update', 'basic', 'feat-branch', false)
|
||||
local updatepre_defbranch = find_event('Pre', 'update', 'defbranch', nil, false)
|
||||
local update_basic = find_event('', 'update', 'basic', 'feat-branch', false)
|
||||
local update_defbranch = find_event('', 'update', 'defbranch', nil, false)
|
||||
local install_basic = find_event('', 'install', 'basic', 'feat-branch', false)
|
||||
local install_defbranch = find_event('', 'install', 'defbranch', nil, false)
|
||||
eq(8, #log)
|
||||
eq(4, #log)
|
||||
|
||||
-- NOTE: There is no guaranteed installation order among separate plugins (as it is async)
|
||||
eq(true, installpre_basic < updatepre_basic)
|
||||
eq(true, updatepre_basic < update_basic)
|
||||
-- NOTE: "Install" is after "update" to indicate installation at correct version
|
||||
eq(true, update_basic < install_basic)
|
||||
|
||||
eq(true, installpre_defbranch < updatepre_defbranch)
|
||||
eq(true, updatepre_defbranch < update_defbranch)
|
||||
eq(true, update_defbranch < install_defbranch)
|
||||
eq(true, installpre_basic < install_basic)
|
||||
eq(true, installpre_defbranch < install_defbranch)
|
||||
end)
|
||||
|
||||
it('recognizes several `version` types', function()
|
||||
|
||||
Reference in New Issue
Block a user