فهرست منبع

Improve update script reliability

Willy-JL 1 سال پیش
والد
کامیت
d0a4e50e25
2فایلهای تغییر یافته به همراه11 افزوده شده و 3 حذف شده
  1. 10 2
      .utils/subtree-subdir-helper.sh
  2. 1 1
      .utils/update-subtree.sh

+ 10 - 2
.utils/subtree-subdir-helper.sh

@@ -30,6 +30,7 @@ if [ -f "${cache}" ]; then
         skip=true
     fi
 fi
+ok=true
 if ! $skip; then
     git checkout "${fetch}"
     exec {capture}>&1
@@ -39,7 +40,14 @@ if ! $skip; then
         git branch -D "${split}"
         git subtree split -P "${subdir}" -b "${split}"
     fi
+    if grep "^fatal: " <<< "$result" > /dev/null; then
+        ok=false
+    fi
     git checkout "${prev}"
-    git subtree "${action}" -P "${path}" "${split}" -m "${action^} ${path} from ${repo}"
+    if $ok; then
+        git subtree "${action}" -P "${path}" "${split}" -m "${action^} ${path} from ${repo}"
+    fi
+fi
+if $ok; then
+    echo "${hash}" > "${cache}"
 fi
-echo "${hash}" > "${cache}"

+ 1 - 1
.utils/update-subtree.sh

@@ -37,7 +37,7 @@ while read -u $remote repo branch subdir; do
     if grep "Please commit your changes or stash them before you switch branches." <<< "$result" > /dev/null; then
         exit 1
     fi
-    if grep "fatal: working tree has modifications." <<< "$result" > /dev/null; then
+    if grep "^fatal: " <<< "$result" > /dev/null; then
         exit 1
     fi
 done {remote}< "${path}/.gitsubtree"