Skip to content

Commit d6cde5a

Browse files
committed
fix(lockfile): Update with fetch/pull based on commit
Depending if there is a commit found the update command will either fetch or pull. It will fetch if there is a commit found else it will pull.
1 parent 79f2af8 commit d6cde5a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

lua/packer/plugin_types/git.lua

+8-9
Original file line numberDiff line numberDiff line change
@@ -224,27 +224,24 @@ end
224224

225225
local get_depth = function(plugin)
226226
if config.is_lockfile then
227-
local info = lockfile.get(plugin.short_name)
228-
return info.date and fmt('--shallow-since="%s"', info.date) or '--depth=999999'
227+
return info.date and fmt(' --shallow-since="%s"', info.date) or ' --depth=999999'
229228
else
230229
local depth = plugin.commit and 999999 or config.depth
231-
return fmt('--depth="%s"', depth)
230+
return fmt(' --depth="%s"', depth)
232231
end
233232
end
234233

235234
git.setup = function(plugin)
235+
local depth_opt = get_depth(plugin)
236236
local plugin_name = util.get_plugin_full_name(plugin)
237237
local install_to = plugin.install_path
238-
local install_cmd = vim.split(config.exec_cmd .. config.subcommands.install, '%s+')
239-
install_cmd[#install_cmd + 1] = get_depth(plugin)
238+
local install_cmd = vim.split(config.exec_cmd .. config.subcommands.install .. depth_opt, '%s+')
240239

241240
local submodule_cmd = config.exec_cmd .. config.subcommands.submodules
242241
local rev_cmd = config.exec_cmd .. config.subcommands.get_rev
243242

244-
local use_fetch = config.is_lockfile or plugin.commit or plugin.tag
245-
local update_subcmd = use_fetch and config.subcommands.fetch or config.subcommands.update
246-
local update_cmd = vim.split(config.exec_cmd .. update_subcmd, '%s+')
247-
update_cmd[#update_cmd + 1] = get_depth(plugin)
243+
local fetch_cmd = vim.split(config.exec_cmd .. config.subcommands.fetch .. depth_opt, '%s+')
244+
local pull_cmd = vim.split(config.exec_cmd .. config.subcommands.update .. depth_opt, '%s+')
248245

249246
local branch_cmd = config.exec_cmd .. config.subcommands.current_branch
250247
local current_commit_cmd = vim.split(config.exec_cmd .. config.subcommands.get_header, '%s+')
@@ -441,6 +438,8 @@ git.setup = function(plugin)
441438

442439
disp:task_update(plugin_name, 'pulling updates...')
443440

441+
local commit = plugin.commit or get_lockfile_info(plugin).commit
442+
local update_cmd = commit and fetch_cmd or pull_cmd
444443
r
445444
:and_then(await, jobs.run(update_cmd, update_opts))
446445
:and_then(await, jobs.run(submodule_cmd, update_opts))

0 commit comments

Comments
 (0)