From 8d100483e0662916cd30e99ceb7216532c58f903 Mon Sep 17 00:00:00 2001 From: Evgeni Chasnovski Date: Sun, 17 May 2026 10:49:48 +0300 Subject: feat(pack): update `get()` to take `rev` from actual repo if `info=true` Problem: `vim.pack.get()` always uses lockfile as the source for the `rev` field. This is fast, but may be misleading in case of a corrupted lockfile. Solution: Compute revision from Git repo on disk if `info=true` (default), use lockfile otherwise. This does increase execution time (as a result of one extra `git ...` call for every plugin), but `info=true` is already designed to be informative and not necessarily fast. --- runtime/lua/vim/pack.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'runtime/lua/vim/pack.lua') diff --git a/runtime/lua/vim/pack.lua b/runtime/lua/vim/pack.lua index bd693904cd..655d6f14d6 100644 --- a/runtime/lua/vim/pack.lua +++ b/runtime/lua/vim/pack.lua @@ -1434,7 +1434,7 @@ end --- @field active boolean Whether plugin was added via |vim.pack.add()| to current session. --- @field branches? string[] Available Git branches (first is default). Missing if `info=false`. --- @field path string Plugin's path on disk. ---- @field rev string Current Git revision. +--- @field rev string Current Git revision. Taken from |vim.pack-lockfile| if `info=false`. --- @field spec vim.pack.SpecResolved A |vim.pack.Spec| with resolved `name`. --- @field tags? string[] Available Git tags. Missing if `info=false`. @@ -1450,6 +1450,7 @@ local function add_p_data_info(p_data_list) --- @async funs[i] = function() p_data.branches = git_get_branches(path) + p_data.rev = git_get_hash('HEAD', path) p_data.tags = git_get_tags(path) end end -- cgit