Prechádzať zdrojové kódy

fix(installer): always use check shallow clones (#2763)

kylo252 3 rokov pred
rodič
commit
12f8798bb0

+ 7 - 5
.github/workflows/install.yaml

@@ -35,17 +35,19 @@ jobs:
     steps:
     steps:
       - uses: actions/checkout@v2
       - uses: actions/checkout@v2
 
 
-      - name: Install neovim binary
-        uses: rhysd/action-setup-vim@v1
-        with:
-          neovim: true
-          version: ${{ matrix.neovim }}
+      - name: Install neovim binary from release
+        env:
+          RELEASE_VER: ${{ matrix.neovim }}
+        run: |
+          echo "$HOME/.local/bin" >> $GITHUB_PATH
+          bash ./utils/installer/install-neovim-from-release
 
 
       - name: Install LunarVim
       - name: Install LunarVim
         timeout-minutes: 4
         timeout-minutes: 4
         env:
         env:
           LV_BRANCH: ${{ github.head_ref || github.ref_name }}
           LV_BRANCH: ${{ github.head_ref || github.ref_name }}
           LV_REMOTE: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
           LV_REMOTE: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
+          LUNARVIM_LOG_LEVEL: "debug"
         run: |
         run: |
           export PATH="$HOME/.local/bin:$PATH"
           export PATH="$HOME/.local/bin:$PATH"
 
 

+ 19 - 9
lua/lvim/core/log.lua

@@ -12,17 +12,27 @@ vim.tbl_add_reverse_lookup(Log.levels)
 local notify_opts = {}
 local notify_opts = {}
 
 
 function Log:set_level(level)
 function Log:set_level(level)
-  -- package.loaded["lvim.core.log"] = nil
-  local log_level = Log.levels[level:upper()]
-  local status_ok, logger = pcall(require("structlog").get_logger, "lvim")
-  if status_ok then
-    for _, s in ipairs(logger.sinks) do
-      s.level = log_level
+  local logger_ok, _ = xpcall(function()
+    local log_level = Log.levels[level:upper()]
+    local structlog = require "structlog"
+    if structlog then
+      local logger = structlog.get_logger "lvim"
+      for _, s in ipairs(logger.sinks) do
+        s.level = log_level
+      end
     end
     end
+  end, debug.traceback)
+  if not logger_ok then
+    Log:debug("Unable to set logger's level: " .. debug.traceback())
   end
   end
 
 
-  package.loaded["packer.log"] = nil
-  require("packer.log").new { level = lvim.log.level }
+  local packer_ok, _ = xpcall(function()
+    package.loaded["packer.log"] = nil
+    require("packer.log").new { level = lvim.log.level }
+  end, debug.traceback)
+  if not packer_ok then
+    Log:debug("Unable to set packer's log level: " .. debug.traceback())
+  end
 end
 end
 
 
 function Log:init()
 function Log:init()
@@ -36,7 +46,7 @@ function Log:init()
     lvim = {
     lvim = {
       sinks = {
       sinks = {
         structlog.sinks.Console(log_level, {
         structlog.sinks.Console(log_level, {
-          async = false,
+          async = true,
           processors = {
           processors = {
             structlog.processors.Namer(),
             structlog.processors.Namer(),
             structlog.processors.StackWriter({ "line", "file" }, { max_parents = 0, stack_level = 2 }),
             structlog.processors.StackWriter({ "line", "file" }, { max_parents = 0, stack_level = 2 }),

+ 8 - 8
lua/lvim/utils/git.lua

@@ -32,20 +32,20 @@ local function git_cmd(opts)
     Log:debug(stdout)
     Log:debug(stdout)
   end
   end
 
 
-  return ret, stdout
+  return ret, stdout, stderr
 end
 end
 
 
 local function safe_deep_fetch()
 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
   if ret ~= 0 then
-    Log:error "Git fetch failed! Check the log for further information"
+    Log:error(vim.inspect(error))
     return
     return
   end
   end
   -- git fetch --unshallow will cause an error on a a complete clone
   -- git fetch --unshallow will cause an error on a a complete clone
   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! Check the log for further information"
+    Log:error("Git fetch failed! Please pull the changes manually in " .. get_lvim_base_dir())
     return
     return
   end
   end
   return true
   return true
@@ -55,12 +55,12 @@ end
 function M.update_base_lvim()
 function M.update_base_lvim()
   Log:info "Checking for updates"
   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
     return
   end
   end
 
 
+  local ret
+
   ret = git_cmd { args = { "diff", "--quiet", "@{upstream}" } }
   ret = git_cmd { args = { "diff", "--quiet", "@{upstream}" } }
   if ret == 0 then
   if ret == 0 then
     Log:info "LunarVim is already up-to-date"
     Log:info "LunarVim is already up-to-date"
@@ -69,7 +69,7 @@ function M.update_base_lvim()
 
 
   ret = git_cmd { args = { "merge", "--ff-only", "--progress" } }
   ret = git_cmd { args = { "merge", "--ff-only", "--progress" } }
   if ret ~= 0 then
   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
     return
   end
   end
 
 

+ 4 - 0
utils/installer/install-neovim-from-release

@@ -72,6 +72,10 @@ function install_neovim() {
   pushd "$DOWNLOAD_DIR"
   pushd "$DOWNLOAD_DIR"
   tar -xzf "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz"
   tar -xzf "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz"
   popd
   popd
+  if [ ! -d "$DOWNLOAD_DIR/$RELEASE_NAME" ]; then
+    # fallback to archive name
+    RELEASE_NAME="$ARCHIVE_NAME"
+  fi
   # https://dev.to/ackshaey/macos-vs-linux-the-cp-command-will-trip-you-up-2p00
   # https://dev.to/ackshaey/macos-vs-linux-the-cp-command-will-trip-you-up-2p00
   cp -r "$DOWNLOAD_DIR/$RELEASE_NAME/." "$LV_INSTALL_PREFIX"
   cp -r "$DOWNLOAD_DIR/$RELEASE_NAME/." "$LV_INSTALL_PREFIX"
   echo "Installation complete!"
   echo "Installation complete!"

+ 3 - 0
utils/installer/install.sh

@@ -15,6 +15,8 @@ declare -r LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$XDG_CONFIG_HOME/lvim"}"
 declare -r LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-"$XDG_CACHE_HOME/lvim"}"
 declare -r LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-"$XDG_CACHE_HOME/lvim"}"
 declare -r LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-"$LUNARVIM_RUNTIME_DIR/lvim"}"
 declare -r LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-"$LUNARVIM_RUNTIME_DIR/lvim"}"
 
 
+declare -r LUNARVIM_LOG_LEVEL="${LUNARVIM_LOG_LEVEL:-warn}"
+
 declare BASEDIR
 declare BASEDIR
 BASEDIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
 BASEDIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
 BASEDIR="$(dirname -- "$(dirname -- "$BASEDIR")")"
 BASEDIR="$(dirname -- "$(dirname -- "$BASEDIR")")"
@@ -423,6 +425,7 @@ function setup_lvim() {
   echo "Preparing Packer setup"
   echo "Preparing Packer setup"
 
 
   "$INSTALL_PREFIX/bin/lvim" --headless \
   "$INSTALL_PREFIX/bin/lvim" --headless \
+    -c "lua require('lvim.core.log'):set_level([[$LUNARVIM_LOG_LEVEL]])" \
     -c 'autocmd User PackerComplete quitall' \
     -c 'autocmd User PackerComplete quitall' \
     -c 'PackerSync'
     -c 'PackerSync'