template_init.command 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/usr/bin/env bash
  2. #
  3. # update template submodules manually
  4. # run once in the main folder after the template has been made by tonic
  5. # Set folder where script will be executed
  6. #loc=$(dirname $0)
  7. #projectdir=$(git -C ${loc} rev-parse --show-toplevel)
  8. #
  9. #pushd ${loc} > /dev/null
  10. # get info for gin remote information
  11. GINinfo="$(gin remotes)"
  12. Gitadress="$(echo $GINinfo | cut -d'/' -f3)"
  13. Orga="$(echo $GINinfo | cut -d'/' -f4)"
  14. repo2="$(echo $GINinfo | cut -d'/' -f5)"
  15. repo="$(echo $repo2 | cut -d' ' -f1)"
  16. reposhort="$(echo "${repo/.main}")"
  17. # add some submodules to labreport repository.
  18. gin git submodule update --init --recursive
  19. if test -f ".notinlabreport.txt" ;
  20. then
  21. # delete file telling the initialisation need to be done
  22. rm ".notinlabreport.txt"
  23. # add submodule to PI repo
  24. # get labreports repo and write new folder for the project
  25. cd ../
  26. gin get ""$Orga""/labreports""
  27. cd labreports
  28. mkdir "$reposhort"
  29. mkdir "$reposhort/05_figures"
  30. # add 2 submodule for figures and dissemination files there
  31. gin git submodule add "../$reposhort.05_figures_990_shared_figures.git" ""$reposhort"/05_figures/990_shared_figures"
  32. gin git submodule add "../$reposhort.06_dissemination" ""$reposhort"/06_dissemination"
  33. # add a file to tell the user/script to initialise the submodules next time.
  34. echo "submodules need intitialisation due to project "$reposhort"." >> "initialise.txt"
  35. gin git add "initialise.txt"
  36. # push changes on the server and remove the repo from the computer.
  37. gin git commit -m "added project $reposhort"
  38. gin upload
  39. cd ../
  40. rm -rf labreports
  41. fi