GIN_sync_UNIX 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env bash
  2. #
  3. ## Double click me to synchornise changes between the mac or linux computer and the server, large files will not be downloaded
  4. ## To allow large file download, please erase the # sign in line 44-45 and save the file
  5. ## use sync-bash if you are on a windows computer
  6. #
  7. # Upload changes from inside repository using GIN CLI
  8. # Assumes no submodules
  9. # Assumes gin init was performed or the repository was downloaded via gin get
  10. if (( $# > 0 )); then
  11. echo "This script takes no arguments"
  12. exit 1
  13. fi
  14. checkerror() {
  15. err=$1
  16. msg=$2
  17. if [[ ${err} != 0 ]]; then
  18. echo ${msg} >> ./log/gin.log
  19. echo ${msg}
  20. echo "Press [Enter] to close this window"
  21. read
  22. exit 1
  23. fi
  24. }
  25. loc=$(dirname $0)
  26. projectdir=$(git -C ${loc} rev-parse --show-toplevel)
  27. pushd ${loc} > /dev/null
  28. mkdir -p ./log
  29. echo "$(date -Iseconds): Sync script executed" >> ./log/gin.log
  30. gin sync
  31. checkerror $? "Error occurred during 'gin sync'"
  32. gin commit .
  33. checkerror $? "Error occurred during 'gin commit'"
  34. gin upload
  35. checkerror $? "Error occurred during 'gin upload'"
  36. # Uncomment the two lines below to download all large files
  37. # gin get-content .
  38. # checkerror $? "Error occurred during 'gin get-content'"
  39. popd > /dev/null