2
0

update.sh 956 B

1234567891011121314151617181920212223242526272829
  1. #!/bin/bash
  2. set -o pipefail
  3. export LC_ALL=C
  4. DATE=$(date)
  5. BRANCH=$(git rev-parse --abbrev-ref HEAD)
  6. # Silently fixing remote url from andryyy to mailcow
  7. git remote set-url origin https://github.com/mailcow/mailcow-dockerized
  8. echo -e "\e[32mCommitting current status...\e[90m"
  9. git add -u
  10. git commit -am "Before update on ${DATE}" > /dev/null
  11. echo -e "\e[32mFetching updated code from remote...\e[90m"
  12. git fetch origin ${BRANCH}
  13. echo -e "\e[32mMerging local with remote code...\e[90m"
  14. git merge -Xtheirs -Xpatience -m "After update on ${DATE}"
  15. if [[ $? == 1 ]]; then
  16. echo -e "\e[31mRun into conflict, trying to fix...\e[90m"
  17. git status --porcelain | grep -E "UD|DU" | awk '{print $2}' | xargs rm -v
  18. git add -A
  19. git commit -m "After update on ${DATE}" > /dev/null
  20. git checkout .
  21. echo -e "\e[32mRemoved and recreated files if necessary.\e[90m"
  22. fi
  23. echo -e "\e[32mDone!\e[0m"
  24. # TODO: Menu, select hard reset etc.
  25. #git reset --hard origin/${BRANCH}