Browse Source

Fix some update scripts

Willy-JL 1 year ago
parent
commit
6e9970ea1c
1 changed files with 11 additions and 5 deletions
  1. 11 5
      .utils/update-subtree.sh

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

@@ -12,15 +12,15 @@ if [ "${1}" = "" ]; then
 fi
 fi
 path="${1}"
 path="${1}"
 
 
-while read repo branch subdir; do
+while read -u $remote repo branch subdir; do
     if [ "${repo:0:1}" = "#" ]; then
     if [ "${repo:0:1}" = "#" ]; then
         continue
         continue
     fi
     fi
-    exec 69>&1
+    exec {capture}>&1
     if [ "${subdir}" = "/" ]; then
     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
     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
     fi
     if grep "Automatic merge failed; fix conflicts and then commit the result." <<< "$result" > /dev/null; then
     if grep "Automatic merge failed; fix conflicts and then commit the result." <<< "$result" > /dev/null; then
         echo "MERGE_MSG: Merge ${path} from ${repo}"
         echo "MERGE_MSG: Merge ${path} from ${repo}"
@@ -34,4 +34,10 @@ while read repo branch subdir; do
             sleep 1
             sleep 1
         done
         done
     fi
     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"