Skip to content

Commit 027daa8

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 8d38634 commit 027daa8

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

lua/packer/plugin_types/git.lua

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,26 +234,24 @@ end
234234
local get_depth = function(plugin)
235235
if config.is_lockfile then
236236
local info = lockfile.get(plugin.short_name)
237-
return info.date and fmt('--shallow-since="%s"', info.date) or '--depth=999999'
237+
return info.date and fmt(' --shallow-since="%s"', info.date) or ' --depth=999999'
238238
else
239239
local depth = plugin.commit and 999999 or config.depth
240-
return fmt('--depth="%s"', depth)
240+
return fmt(' --depth="%s"', depth)
241241
end
242242
end
243243

244244
git.setup = function(plugin)
245+
local depth_opt = get_depth(plugin)
245246
local plugin_name = util.get_plugin_full_name(plugin)
246247
local install_to = plugin.install_path
247-
local install_cmd = vim.split(config.exec_cmd .. config.subcommands.install, '%s+')
248-
install_cmd[#install_cmd + 1] = get_depth(plugin)
248+
local install_cmd = vim.split(config.exec_cmd .. config.subcommands.install .. depth_opt, '%s+')
249249

250250
local submodule_cmd = config.exec_cmd .. config.subcommands.submodules
251251
local rev_cmd = config.exec_cmd .. config.subcommands.get_rev
252252

253-
local use_fetch = config.is_lockfile or plugin.commit or plugin.tag
254-
local update_subcmd = use_fetch and config.subcommands.fetch or config.subcommands.update
255-
local update_cmd = vim.split(config.exec_cmd .. update_subcmd, '%s+')
256-
update_cmd[#update_cmd + 1] = get_depth(plugin)
253+
local fetch_cmd = vim.split(config.exec_cmd .. config.subcommands.fetch .. depth_opt, '%s+')
254+
local pull_cmd = vim.split(config.exec_cmd .. config.subcommands.update .. depth_opt, '%s+')
257255

258256
local branch_cmd = config.exec_cmd .. config.subcommands.current_branch
259257
local current_commit_cmd = vim.split(config.exec_cmd .. config.subcommands.get_header, '%s+')
@@ -450,6 +448,8 @@ git.setup = function(plugin)
450448

451449
disp:task_update(plugin_name, 'pulling updates...')
452450

451+
local commit = plugin.commit or get_lockfile_info(plugin).commit
452+
local update_cmd = commit and fetch_cmd or pull_cmd
453453
r
454454
:and_then(await, jobs.run(update_cmd, update_opts))
455455
:and_then(await, jobs.run(submodule_cmd, update_opts))

0 commit comments

Comments
 (0)