浏览代码

[Feature] Fetch from git before update in install script (#1409)

Lee Marlow 3 年之前
父节点
当前提交
21d04257a8
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      utils/installer/install.sh

+ 4 - 3
utils/installer/install.sh

@@ -211,7 +211,7 @@ function backup_old_config() {
     # that require an existing directory
     mkdir -p "$dir" "$dir.bak"
     if command -v rsync &>/dev/null; then
-      rsync --archive -hh --partial --progress \
+      rsync --archive -hh --partial --progress --cvs-exclude \
         --modify-window=1 "$dir"/ "$dir.bak"
     else
       cp -R "$dir/*" "$dir.bak/."
@@ -273,8 +273,9 @@ function setup_lvim() {
 }
 
 function update_lvim() {
-  if ! git -C "$LUNARVIM_RUNTIME_DIR/lvim" status -uno &>/dev/null; then
-    git -C "$LUNARVIM_RUNTIME_DIR/lvim" pull --ff-only --progress ||
+  git -C "$LUNARVIM_RUNTIME_DIR/lvim" fetch --quiet
+  if ! git -C "$LUNARVIM_RUNTIME_DIR/lvim" diff --quiet "@{upstream}"; then
+    git -C "$LUNARVIM_RUNTIME_DIR/lvim" merge --ff-only --progress ||
       echo "Unable to guarantee data integrity while updating. Please do that manually instead." && exit 1
   fi
   echo "Your LunarVim installation is now up to date!"