diff options
Diffstat (limited to 'lua/lvim/utils')
| -rw-r--r-- | lua/lvim/utils/git.lua | 15 | 
1 files changed, 14 insertions, 1 deletions
| diff --git a/lua/lvim/utils/git.lua b/lua/lvim/utils/git.lua index 99c178f3..e1b5ccf2 100644 --- a/lua/lvim/utils/git.lua +++ b/lua/lvim/utils/git.lua @@ -1,6 +1,7 @@  local M = {}  local Log = require "lvim.core.log" +local fmt = string.format  local if_nil = vim.F.if_nil  local function git_cmd(opts) @@ -43,9 +44,16 @@ local function safe_deep_fetch()    local fetch_mode = result[1] == "true" and "--unshallow" or "--all"    ret = git_cmd { args = { "fetch", fetch_mode } }    if ret ~= 0 then -    Log:error("Git fetch failed! Please pull the changes manually in " .. get_lvim_base_dir()) +    Log:error(fmt "Git fetch %s failed! Please pull the changes manually in %s", fetch_mode, get_lvim_base_dir())      return    end +  if fetch_mode == "--unshallow" then +    ret = git_cmd { args = { "remote", "set-branches", "origin", "*" } } +    if ret ~= 0 then +      Log:error(fmt "Git fetch %s failed! Please pull the changes manually in %s", fetch_mode, get_lvim_base_dir()) +      return +    end +  end    return true  end @@ -53,6 +61,11 @@ end  function M.update_base_lvim()    Log:info "Checking for updates" +  if not vim.loop.fs_access(get_lvim_base_dir(), "w") then +    Log:warn(fmt("Lunarvim update aborted! cannot write to %s", get_lvim_base_dir())) +    return +  end +    if not safe_deep_fetch() then      return    end | 
