.check-merge.sh 967 B

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