Synchronizing Git Submodules Modifying URLs


SUBMITTED BY: itsDaveLad

DATE: March 10, 2016, 3:28 p.m.

FORMAT: Text only

SIZE: 714 Bytes

HITS: 811

  1. # Synchronizing Git Submodules Modifying URLs
  2. Sometimes it is not possible to access submodules as they were registered. Solution is here:
  3. ```{.bash}
  4. #!/bin/bash
  5. NUMARGS=$#
  6. SCRIPT=`basename ${BASH_SOURCE[0]}`
  7. GREEN='\033[1;32m'
  8. NC='\033[0m'
  9. function HELP {
  10. echo -e "${GREEN}Usage${NC}: ${SCRIPT} server-name ip-address timeout-sec"
  11. exit 1
  12. }
  13. if [ $NUMARGS -ne 3 ]; then
  14. HELP
  15. fi
  16. name=$1
  17. address=$2
  18. timeout=$3
  19. rc=1
  20. while [ $rc -ne 0 ]; do
  21. find ./ -type f \( -name .gitmodules \) -print0 | xargs -0 sed -i "s/$name/$address/g"
  22. git submodule sync --recursive
  23. timeout $timeout git submodule update --init --recursive
  24. rc=$?
  25. done
  26. echo -e "${GREEN}All done.${NC}"
  27. ```

comments powered by Disqus