mirror of
https://github.com/neovim/neovim.git
synced 2025-10-22 17:11:49 +00:00
fix(pack): ensure explicit default version in events (where possible)
Problem: Both `PackChangedPre` and `PackChanged` contain |event-data|
with plugin's `spec`. It looks like a good idea to have all its
triggers contain the same format across all kinds ("install",
"update", "delete"). There are several choices:
- Have it be as verbatim as supplied to `vim.pack.add()`, i.e. can
be either string or table. A bit too ambiguous.
- Have it be table with `src` and `name` inferred. This requires
less work for "install", but more work for "update" and "delete"
(since they use `vim.pack.get()` which already infers default
`version`).
- Have it be table with *all* defaults made explicit. This looks
like the best approach, but requires extra care to only infer
default `version` when needed (i.e. avoid inferring during regular
load) because it is costly in terms of startup time.
This might also introduce inconsistency when dealing with
lockfile(s) as information there should be as close to what user
supplied as possible. Address that when dealing with lockfile.
Solution: Ensure explicit `version` in all events where possible.
This commit is contained in:
@@ -291,7 +291,7 @@ Available events to hook into ~
|
||||
Each event populates the following |event-data| fields:
|
||||
• `kind` - one of "install" (install on disk), "update" (update existing
|
||||
plugin), "delete" (delete from disk).
|
||||
• `spec` - plugin's specification.
|
||||
• `spec` - plugin's specification with defaults made explicit.
|
||||
• `path` - full path to plugin's directory.
|
||||
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
--- Each event populates the following |event-data| fields:
|
||||
--- - `kind` - one of "install" (install on disk), "update" (update existing
|
||||
--- plugin), "delete" (delete from disk).
|
||||
--- - `spec` - plugin's specification.
|
||||
--- - `spec` - plugin's specification with defaults made explicit.
|
||||
--- - `path` - full path to plugin's directory.
|
||||
|
||||
local api = vim.api
|
||||
@@ -569,6 +569,9 @@ local function install_list(plug_list)
|
||||
git_clone(p.spec.src, p.path)
|
||||
p.info.installed = true
|
||||
|
||||
-- Infer default branch for fuller `event-data`
|
||||
p.spec.version = p.spec.version or git_get_default_branch(p.path)
|
||||
|
||||
-- Do not skip checkout even if HEAD and target have same commit hash to
|
||||
-- have new repo in expected detached HEAD state and generated help files.
|
||||
checkout(p, timestamp, false)
|
||||
|
||||
Reference in New Issue
Block a user