summaryrefslogtreecommitdiff
path: root/lua/lvim/utils/git.lua
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2022-10-17 17:29:15 +0200
committerkylo252 <[email protected]>2022-10-17 17:29:15 +0200
commit4ef07315003f723bb8e97d5a91b2bde3773ec1b8 (patch)
treee9889a492f76e3f9573228343aaba647dfd48136 /lua/lvim/utils/git.lua
parente4a5fe97abe500bbbe78fb137d57a59f558da05a (diff)
parent6f6cbc394d2a7e64964b6067a2f42d2e6a07824e (diff)
Merge remote-tracking branch 'origin/rolling'
Diffstat (limited to 'lua/lvim/utils/git.lua')
-rw-r--r--lua/lvim/utils/git.lua17
1 files changed, 15 insertions, 2 deletions
diff --git a/lua/lvim/utils/git.lua b/lua/lvim/utils/git.lua
index 99c178f3..c1bdca1b 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)
@@ -39,13 +40,20 @@ local function safe_deep_fetch()
Log:error(vim.inspect(error))
return
end
- -- git fetch --unshallow will cause an error on a a complete clone
+ -- git fetch --unshallow will cause an error on a complete clone
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