sync-gin-unix 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/env bash
  2. #
  3. # Initialise or Upload changes from inside repository
  4. # using GIN CLI
  5. # Works with submodules and repo made by tonic v1 (not copying submodules content).
  6. # needs git config to be set
  7. # needs SSH access to GIN
  8. # future dvt using datalad will allow use of non-GIN repositories
  9. # logic: template has a specific file to label it needs initialisation.
  10. # if this file is present, code 1 is done: template_initialisation
  11. # if it is absent but submodules are empty, code 2 is done: submodule_initialisation
  12. # if none of the above code 3 is done: synchronisation
  13. # Set folder where script will be executed
  14. loc=$(dirname $0)
  15. projectdir=$(git -C ${loc} rev-parse --show-toplevel)
  16. pushd ${loc} > /dev/null
  17. ## set gin server and remote
  18. sh .scripts/setginserver
  19. #login if needed
  20. if ! gin info; then
  21. echo "set gin login"
  22. gin login
  23. else
  24. echo "gin logged"
  25. fi
  26. ## code 1, add to labreports
  27. if test -f ".notinlabreport.txt" ;
  28. then
  29. echo "Adding project to labreports repository."
  30. sh .scripts/template_init.command
  31. fi
  32. ## code 2, initialising
  33. if grep -q 06_dissemination ".gitmodules";
  34. then
  35. if (test -f "06_dissemination/README_DISSEMINATION.md") ;
  36. then
  37. echo "submodules are initialised"
  38. else
  39. echo "initialising submodules"
  40. gin git submodule update --init --recursive
  41. gin git submodule foreach gin init
  42. fi
  43. else
  44. echo "not a tonic repo, please initialise submodules manually if there are any"
  45. fi
  46. ## code 3
  47. usage() {
  48. echo "$0 <sync-option>"
  49. echo
  50. echo "<sync-option> The sync option defines what to do with the content of large files."
  51. echo " It should be one of the following values:"
  52. echo " download - Download all large file content from the server"
  53. echo " keep - Keep all large file content but do not download missing large files"
  54. echo " remove - Do not download large files and remove existing local large file content"
  55. exit 1
  56. }
  57. # Set the variable for synchronisation option, see above
  58. syncopt="remove"
  59. echo "start synchronisation in "$syncopt" mode, close window to cancel. change mode by changing the code in a text application"
  60. sh .scripts/GIN-SYNC