You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
1.1 KiB

  1. #!/bin/bash
  2. staticPathSubstitution="\$\$\${GITSUBSTITUTE_REPO_ROOT}"
  3. oneOrMoreSubstitutedFileExists="false"
  4. # if checkout is a branch checkout
  5. if [ $3 == "1" ]; then
  6. echo "Looking for files to substitute..."
  7. repoRoot=$(git rev-parse --show-toplevel)
  8. listFilesToSubstitute=$(find -name *.gitsubstitute)
  9. for fileToSubstitute in $listFilesToSubstitute; do
  10. if ! [ -f ${fileToSubstitute%.gitsubstitute} ]; then
  11. echo "create file: ${fileToSubstitute%.gitsubstitute}"
  12. fullPath="${repoRoot}/${fileToSubstitute}"
  13. fullPathSubstitute="${repoRoot}/${fileToSubstitute%.gitsubstitute}"
  14. fileContent=$(<$fullPath)
  15. echo "${fileContent//${staticPathSubstitution}/${repoRoot}}" > "${fullPathSubstitute}"
  16. else
  17. oneOrMoreSubstitutedFileExists="true"
  18. fi
  19. done
  20. if [ $oneOrMoreSubstitutedFileExists == "true" ]; then
  21. echo "One or more substituted file exists."
  22. echo "If you want to clean the repo and recreate all projects run './clean_and_recreate_all'"
  23. fi
  24. fi