|
@@ -1,6 +1,7 @@
|
|
local M = {}
|
|
local M = {}
|
|
|
|
|
|
local Log = require "lvim.core.log"
|
|
local Log = require "lvim.core.log"
|
|
|
|
+local fmt = string.format
|
|
local if_nil = vim.F.if_nil
|
|
local if_nil = vim.F.if_nil
|
|
|
|
|
|
local function git_cmd(opts)
|
|
local function git_cmd(opts)
|
|
@@ -43,9 +44,16 @@ local function safe_deep_fetch()
|
|
local fetch_mode = result[1] == "true" and "--unshallow" or "--all"
|
|
local fetch_mode = result[1] == "true" and "--unshallow" or "--all"
|
|
ret = git_cmd { args = { "fetch", fetch_mode } }
|
|
ret = git_cmd { args = { "fetch", fetch_mode } }
|
|
if ret ~= 0 then
|
|
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
|
|
return
|
|
end
|
|
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
|
|
return true
|
|
end
|
|
end
|
|
|
|
|
|
@@ -53,6 +61,11 @@ end
|
|
function M.update_base_lvim()
|
|
function M.update_base_lvim()
|
|
Log:info "Checking for updates"
|
|
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
|
|
if not safe_deep_fetch() then
|
|
return
|
|
return
|
|
end
|
|
end
|