瀏覽代碼

Fix some update scripts

Willy-JL 2 年之前
父節點
當前提交
6e9970ea1c
共有 1 個文件被更改,包括 11 次插入5 次删除
  1. 11 5
      .utils/update-subtree.sh

+ 11 - 5
.utils/update-subtree.sh

@@ -12,15 +12,15 @@ if [ "${1}" = "" ]; then
 fi
 path="${1}"
 
-while read repo branch subdir; do
+while read -u $remote repo branch subdir; do
     if [ "${repo:0:1}" = "#" ]; then
         continue
     fi
-    exec 69>&1
+    exec {capture}>&1
     if [ "${subdir}" = "/" ]; then
-        result="$(git subtree pull -P "${path}" "${repo}" "${branch}" -m "Merge ${path} from ${repo}" 2>&1 | tee /proc/self/fd/69)"
+        result="$(git subtree pull -P "${path}" "${repo}" "${branch}" -m "Merge ${path} from ${repo}" 2>&1 | tee /proc/self/fd/$capture)"
     else
-        result="$(bash .utils/subtree-subdir-helper.sh "${path}" "${repo}" "${branch}" "${subdir}" merge 2>&1 | tee /proc/self/fd/69)"
+        result="$(bash .utils/subtree-subdir-helper.sh "${path}" "${repo}" "${branch}" "${subdir}" merge 2>&1 | tee /proc/self/fd/$capture)"
     fi
     if grep "Automatic merge failed; fix conflicts and then commit the result." <<< "$result" > /dev/null; then
         echo "MERGE_MSG: Merge ${path} from ${repo}"
@@ -34,4 +34,10 @@ while read repo branch subdir; do
             sleep 1
         done
     fi
-done < "${path}/.gitsubtree"
+    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
+        exit 1
+    fi
+done {remote}< "${path}/.gitsubtree"