diff options
| author | Evgeni Chasnovski <evgeni.chasnovski@gmail.com> | 2025-10-04 16:15:54 +0300 |
|---|---|---|
| committer | Evgeni Chasnovski <evgeni.chasnovski@gmail.com> | 2025-10-04 16:15:54 +0300 |
| commit | dc8235c48c8be65659f75461d8cb185ab1941d0f (patch) | |
| tree | 145c9edd5f57980f17436c9551ffd5c5a1b721c8 /runtime/lua/vim/pack.lua | |
| parent | cfbc03a9549017984a2ca9c139553aac1c016a42 (diff) | |
| download | rneovim-dc8235c48c8be65659f75461d8cb185ab1941d0f.tar.gz rneovim-dc8235c48c8be65659f75461d8cb185ab1941d0f.tar.bz2 rneovim-dc8235c48c8be65659f75461d8cb185ab1941d0f.zip | |
feat(pack): prefer using revision from lockfile during install
Problem: Installing plugin always pulls latest `version` changes
(usually from the default branch or "latest version tag"). It is more
robust to prefer initial installation to use the latest recorded
(i.e. "working") revision.
Solution: Prefer using revision from the lockfile (if present) during
install. The extra `update()` will pull the latest changes.
Diffstat (limited to 'runtime/lua/vim/pack.lua')
| -rw-r--r-- | runtime/lua/vim/pack.lua | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/runtime/lua/vim/pack.lua b/runtime/lua/vim/pack.lua index 268f43e063..6790350bc3 100644 --- a/runtime/lua/vim/pack.lua +++ b/runtime/lua/vim/pack.lua @@ -18,7 +18,8 @@ ---located at `$XDG_CONFIG_HOME/nvim/nvim-pack-lock.json`. It is a JSON file that ---is used to persistently track data about plugins. ---For a more robust config treat lockfile like its part: put under version control, etc. ----Should not be edited by hand or deleted. +---In this case initial install prefers revision from the lockfile instead of +---inferring from `version`. Should not be edited by hand or deleted. --- ---Example workflows ~ --- @@ -56,7 +57,8 @@ ---``` --- ---- Restart Nvim (for example, with |:restart|). Plugins that were not yet ----installed will be available on disk in target state after `add()` call. +---installed will be available on disk after `add()` call. Their revision is +---taken from |vim.pack-lockfile| (if present) or inferred from the `version`. --- ---- To update all plugins with new changes: --- - Execute |vim.pack.update()|. This will download updates from source and @@ -625,6 +627,9 @@ local function install_list(plug_list, confirm) plugin_lock.plugins[p.spec.name].src = p.spec.src + -- Prefer revision from the lockfile instead of using `version` + p.info.sha_target = (plugin_lock.plugins[p.spec.name] or {}).rev + -- 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) |