mirror of
https://github.com/neovim/neovim.git
synced 2026-02-20 09:19:43 +10:00
fix(pack): skip git stash during install
Problem: Installing plugin is done via `git clone --no-checkout ...` (to not end up with default branch code in case of invalid `version`). This leaves cloned repo in a state that `git stash` will actually add an entry to the stash list. Although not critical, better to not have that if possible. Solution: explicitly skip `git stash` step in checkout during install.
This commit is contained in:
@@ -654,15 +654,18 @@ end
|
||||
--- @async
|
||||
--- @param p vim.pack.Plug
|
||||
--- @param timestamp string
|
||||
local function checkout(p, timestamp)
|
||||
--- @param skip_stash? boolean
|
||||
local function checkout(p, timestamp, skip_stash)
|
||||
infer_revisions(p)
|
||||
|
||||
local stash_cmd = { 'stash', '--quiet' }
|
||||
if git_version > vim.version.parse('2.13') then
|
||||
stash_cmd[#stash_cmd + 1] = '--message'
|
||||
stash_cmd[#stash_cmd + 1] = ('vim.pack: %s Stash before checkout'):format(timestamp)
|
||||
if not skip_stash then
|
||||
local stash_cmd = { 'stash', '--quiet' }
|
||||
if git_version > vim.version.parse('2.13') then
|
||||
stash_cmd[#stash_cmd + 1] = '--message'
|
||||
stash_cmd[#stash_cmd + 1] = ('vim.pack: %s Stash before checkout'):format(timestamp)
|
||||
end
|
||||
git_cmd(stash_cmd, p.path)
|
||||
end
|
||||
git_cmd(stash_cmd, p.path)
|
||||
|
||||
git_cmd({ 'checkout', '--quiet', p.info.sha_target }, p.path)
|
||||
|
||||
@@ -691,7 +694,7 @@ local function install_list(plug_list, confirm)
|
||||
-- Prefer revision from the lockfile instead of using `version`
|
||||
p.info.sha_target = (plugin_lock.plugins[p.spec.name] or {}).rev
|
||||
|
||||
checkout(p, timestamp)
|
||||
checkout(p, timestamp, true)
|
||||
p.info.installed = true
|
||||
|
||||
trigger_event(p, 'PackChanged', 'install')
|
||||
|
||||
@@ -369,6 +369,11 @@ describe('vim.pack', function()
|
||||
vim.pack.add({ repos_src.basic })
|
||||
end)
|
||||
eq(exec_lua('return #_G.event_log'), 0)
|
||||
|
||||
-- Should not create redundant stash entry
|
||||
local basic_path = pack_get_plug_path('basic')
|
||||
local stash_list = system_sync({ 'git', 'stash', 'list' }, { cwd = basic_path }).stdout or ''
|
||||
eq('', stash_list)
|
||||
end)
|
||||
|
||||
it('passes `data` field through to `opts.load`', function()
|
||||
|
||||
Reference in New Issue
Block a user