.check-merge.sh 867 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. set -e
  3. if [ "${1}" = "" ] || [ "${2}" = "" ]; then
  4. echo "Usage: <path> <repo url> <merge output>"
  5. exit
  6. fi
  7. path="${1}"
  8. repo="${2}"
  9. result="${3}"
  10. if grep "Automatic merge failed; fix conflicts and then commit the result." <<< "$result" > /dev/null; then
  11. echo "MERGE_MSG: Merge ${path} from ${repo}"
  12. notify-send -t 0 -a Git -i git "Subtree merge failed" "Resolve current index to continue" &> /dev/null | true
  13. while true; do
  14. echo "Resolve current index then press Enter..."
  15. read
  16. if git diff --quiet && git diff --cached --quiet && git merge HEAD &> /dev/null; then
  17. break
  18. fi
  19. sleep 1
  20. done
  21. fi
  22. if grep "Please commit your changes or stash them before you switch branches." <<< "$result" > /dev/null; then
  23. exit 1
  24. fi
  25. if grep "^fatal: " <<< "$result" > /dev/null; then
  26. exit 1
  27. fi