push 873 B

123456789101112131415161718192021222324252627
  1. #!/bin/bash
  2. set -e
  3. trap onexit EXIT SIGINT
  4. onexit() {
  5. set +e
  6. /usr/bin/sync || time '/home/user/bin/sync'
  7. gpgconf --kill gpg-agent
  8. }
  9. git push backupto
  10. /usr/bin/sync || time '/home/user/bin/sync'
  11. if [[ "$1" =~ back ]]; then
  12. echo 'Done pushing only backup'
  13. exit 0
  14. fi
  15. changecolor() {
  16. sed -re 's/^(fatal:.*)$/'"$(tput setab 1)"'\1'"$(tput sgr0)"'/'
  17. #^ the 'sed' is needed to highlight the errors which if they happen the exitcode will still be zero!(possibly due to the first remote succeeding!) TODO: fix 'git' to exit code non zero if any of the repos/urls listed in remote 'origin'(for example) fail.
  18. }
  19. time git push -u --all --follow-tags origin |& changecolor
  20. #time git push -u --tags origin |& changecolor #obsolted by the above ^ --follow-tags
  21. #the -u is only needed the first time, or if you've use -u for other remotes like backupto!
  22. echo "All done"