diff options
author | kylo252 <[email protected]> | 2022-07-31 14:28:43 +0200 |
---|---|---|
committer | kylo252 <[email protected]> | 2022-07-31 14:28:43 +0200 |
commit | 6fbefdacd35f03b8146490613c54e7865d06a77f (patch) | |
tree | 70e378c86c411b4c959e7f04851263fc96ad752e /lua/lvim/utils/git.lua | |
parent | b04aefbb79670b115f4f363906d6d294b3d0a2a3 (diff) | |
parent | dec21bbab6cf9102e236806e20273d08f32f8716 (diff) |
Merge branch 'rolling'
Diffstat (limited to 'lua/lvim/utils/git.lua')
-rw-r--r-- | lua/lvim/utils/git.lua | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/lua/lvim/utils/git.lua b/lua/lvim/utils/git.lua index 81b1faf4..99c178f3 100644 --- a/lua/lvim/utils/git.lua +++ b/lua/lvim/utils/git.lua @@ -13,16 +13,14 @@ local function git_cmd(opts) opts.cwd = opts.cwd or get_lvim_base_dir() local stderr = {} - local stdout, ret = Job - :new({ - command = "git", - args = opts.args, - cwd = opts.cwd, - on_stderr = function(_, data) - table.insert(stderr, data) - end, - }) - :sync() + local stdout, ret = Job:new({ + command = "git", + args = opts.args, + cwd = opts.cwd, + on_stderr = function(_, data) + table.insert(stderr, data) + end, + }):sync() if not vim.tbl_isempty(stderr) then Log:debug(stderr) @@ -32,20 +30,20 @@ local function git_cmd(opts) Log:debug(stdout) end - return ret, stdout + return ret, stdout, stderr end local function safe_deep_fetch() - local ret, result = git_cmd { args = { "rev-parse", "--is-shallow-repository" } } + local ret, result, error = git_cmd { args = { "rev-parse", "--is-shallow-repository" } } if ret ~= 0 then - Log:error "Git fetch failed! Check the log for further information" + Log:error(vim.inspect(error)) return end -- git fetch --unshallow will cause an error on a 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! Check the log for further information" + Log:error("Git fetch failed! Please pull the changes manually in " .. get_lvim_base_dir()) return end return true @@ -55,12 +53,12 @@ end function M.update_base_lvim() Log:info "Checking for updates" - local ret = git_cmd { args = { "fetch" } } - if ret ~= 0 then - Log:error "Update failed! Check the log for further information" + if not safe_deep_fetch() then return end + local ret + ret = git_cmd { args = { "diff", "--quiet", "@{upstream}" } } if ret == 0 then Log:info "LunarVim is already up-to-date" @@ -69,7 +67,7 @@ function M.update_base_lvim() ret = git_cmd { args = { "merge", "--ff-only", "--progress" } } if ret ~= 0 then - Log:error "Update failed! Please pull the changes manually instead." + Log:error("Update failed! Please pull the changes manually in " .. get_lvim_base_dir()) return end |