Skip to content

Commit e9c523d

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 e9c523d

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
@@ -225,26 +225,24 @@ end
225225
local get_depth = function(plugin)
226226
if config.is_lockfile then
227227
local info = lockfile.get(plugin.short_name)
228-
return info.date and fmt('--shallow-since="%s"', info.date) or '--depth=999999'
228+
return info.date and fmt(' --shallow-since="%s"', info.date) or ' --depth=999999'
229229
else
230230
local depth = plugin.commit and 999999 or config.depth
231-
return fmt('--depth="%s"', depth)
231+
return fmt(' --depth="%s"', depth)
232232
end
233233
end
234234

235235
git.setup = function(plugin)
236+
local depth_opt = get_depth(plugin)
236237
local plugin_name = util.get_plugin_full_name(plugin)
237238
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)
239+
local install_cmd = vim.split(config.exec_cmd .. config.subcommands.install .. depth_opt, '%s+')
240240

241241
local submodule_cmd = config.exec_cmd .. config.subcommands.submodules
242242
local rev_cmd = config.exec_cmd .. config.subcommands.get_rev
243243

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)
244+
local fetch_cmd = vim.split(config.exec_cmd .. config.subcommands.fetch .. depth_opt, '%s+')
245+
local pull_cmd = vim.split(config.exec_cmd .. config.subcommands.update .. depth_opt, '%s+')
248246

249247
local branch_cmd = config.exec_cmd .. config.subcommands.current_branch
250248
local current_commit_cmd = vim.split(config.exec_cmd .. config.subcommands.get_header, '%s+')
@@ -441,6 +439,8 @@ git.setup = function(plugin)
441439

442440
disp:task_update(plugin_name, 'pulling updates...')
443441

442+
local commit = plugin.commit or get_lockfile_info(plugin).commit
443+
local update_cmd = commit and fetch_cmd or pull_cmd
444444
r
445445
:and_then(await, jobs.run(update_cmd, update_opts))
446446
:and_then(await, jobs.run(submodule_cmd, update_opts))

0 commit comments

Comments
 (0)