summaryrefslogtreecommitdiff
path: root/lua/lvim/utils/git.lua
diff options
context:
space:
mode:
authorkylo252 <[email protected]>2022-10-07 04:51:09 +0200
committerGitHub <[email protected]>2022-10-06 22:51:09 -0400
commitf6402563abb3ace148168a27e7889c961dd94bfd (patch)
tree028cd4e2b397802d582ef7e9f35d3c8eb159f7a4 /lua/lvim/utils/git.lua
parent40e2d5a1715ab7cdb0c4b4d849f1628caadb6842 (diff)
feat: enable global installation (#3161)
Diffstat (limited to 'lua/lvim/utils/git.lua')
-rw-r--r--lua/lvim/utils/git.lua15
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