update-subtrees.sh 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/bash
  2. set -e
  3. bash .utils/.check-workdir.sh
  4. if [ "${1}" = "" ]; then
  5. shopt -s globstar
  6. subtrees=(**/.gitsubtree)
  7. else
  8. subtrees=($*)
  9. fi
  10. for subtree in "${subtrees[@]}"; do
  11. if [[ "${subtree}" != */.gitsubtree ]]; then
  12. subtree="${subtree}/.gitsubtree"
  13. fi
  14. path="$(dirname "${subtree}")"
  15. echo -e "\n\nUpdating ${path}..."
  16. while read -u $remote repo branch subdir; do
  17. if [ "${repo:0:1}" = "#" ]; then
  18. continue
  19. fi
  20. if [ "${subdir}" = "/" ]; then
  21. exec {capture}>&1
  22. result="$(git subtree pull -P "${path}" "${repo}" "${branch}" -m "Merge ${path} from ${repo}" 2>&1 | tee /proc/self/fd/$capture)"
  23. bash .utils/.check-merge.sh "${path}" "${repo}" "${result}"
  24. else
  25. bash .utils/.subtree-subdir-helper.sh "${path}" "${repo}" "${branch}" "${subdir}" merge
  26. fi
  27. done {remote}< "${subtree}"
  28. done
  29. notify-send -t 0 -a Git -i git "Subtree update finished" "Double check merge commits" &> /dev/null | true