pull_repos.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/bash
  2. #
  3. # This is script is written to fetch and keep updated GIT repositories.
  4. # Bear in mind, that before repo pull, hard reset will be done for two reasons:
  5. # 1) to reset local changes and avoid mess with main stream
  6. # 2) makes a habit to submit changes immedeately, mostly applies to password databases)
  7. #
  8. #
  9. # 2021 09 00 + init /A
  10. # 2022 03 19 * this script is written to hard reset repositories and pull
  11. # 2022 08 05 * changed message /A
  12. # 2023-01-17 * adapted for new structure /A
  13. # 2023-05-23 + show repo's path /A
  14. # - disabled hard reset /A
  15. # 2024-05-06 * moved public, as seen helpful for daily works /A
  16. #
  17. #
  18. # Logic:
  19. #
  20. # path1
  21. # \____host1
  22. # \____repo1
  23. # \____repo2
  24. # \____repo3
  25. # path2
  26. # \____host1
  27. # | \____repo1
  28. # | \____repo2
  29. # | \____repo3
  30. # \____host2
  31. # \____repo1
  32. # \____repo2
  33. # \____repo3
  34. # \____repo4
  35. # \____repo5
  36. #
  37. # TODO:
  38. # 2022-09-06 + check existance of repo, before git reset and pull
  39. # location for github repositories hosts
  40. paths=(
  41. '/Users/anton/dox-w/path-to-repos/'
  42. )
  43. for path in "${paths[@]}" ; do
  44. printf "\n\nPath: [${path}]"
  45. if [[ -d "${path}" ]]
  46. then
  47. printf "\n\nPath: [${path}] exists."
  48. cd ${path}
  49. for host in */ ; do
  50. printf "\n\n\nHost: [${host}]:"
  51. cd ${host}
  52. for repo in */ ; do
  53. printf "\nRepo: [${repo}]:"
  54. cd ${repo}
  55. printf "\nPath: [$(pwd)]:"
  56. # disabled reset for a while
  57. # git reset --hard
  58. git pull --ff-only
  59. cd ..
  60. done
  61. cd ..
  62. done
  63. fi
  64. done