sync 990 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env bash
  2. #
  3. # Upload changes from inside repository using GIN CLI
  4. # Assumes no submodules
  5. # Assumes gin init was performed or the repository was downloaded via gin get
  6. if (( $# > 0 )); then
  7. echo "This script takes no arguments"
  8. exit 1
  9. fi
  10. checkerror() {
  11. err=$1
  12. msg=$2
  13. if [[ ${err} != 0 ]]; then
  14. echo ${msg} >> ./log/gin.log
  15. echo ${msg}
  16. echo "Press [Enter] to close this window"
  17. read
  18. exit 1
  19. fi
  20. }
  21. loc=$(dirname $0)
  22. projectdir=$(git -C ${loc} rev-parse --show-toplevel)
  23. pushd ${loc} > /dev/null
  24. mkdir -p ./log
  25. echo "$(date -Iseconds): Sync script executed" >> ./log/gin.log
  26. gin sync
  27. checkerror $? "Error occurred during 'gin sync'"
  28. gin commit .
  29. checkerror $? "Error occurred during 'gin commit'"
  30. gin upload
  31. checkerror $? "Error occurred during 'gin upload'"
  32. # Uncomment the two lines below to download all large files
  33. # gin get-content .
  34. # checkerror $? "Error occurred during 'gin get-content'"
  35. popd > /dev/null