Skip to content

Commit

Permalink
fix(lockfile): Update with fetch/pull based on commit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
EdenEast committed Aug 12, 2022
1 parent 79f2af8 commit d6cde5a
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions lua/packer/plugin_types/git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -224,27 +224,24 @@ end

local get_depth = function(plugin)
if config.is_lockfile then
local info = lockfile.get(plugin.short_name)
return info.date and fmt('--shallow-since="%s"', info.date) or '--depth=999999'
return info.date and fmt(' --shallow-since="%s"', info.date) or ' --depth=999999'
else
local depth = plugin.commit and 999999 or config.depth
return fmt('--depth="%s"', depth)
return fmt(' --depth="%s"', depth)
end
end

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

local submodule_cmd = config.exec_cmd .. config.subcommands.submodules
local rev_cmd = config.exec_cmd .. config.subcommands.get_rev

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

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

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

local commit = plugin.commit or get_lockfile_info(plugin).commit
local update_cmd = commit and fetch_cmd or pull_cmd
r
:and_then(await, jobs.run(update_cmd, update_opts))
:and_then(await, jobs.run(submodule_cmd, update_opts))
Expand Down

0 comments on commit d6cde5a

Please sign in to comment.