#!/bin/bash staticPathSubstitution="\$\$\${GITSUBSTITUTE_REPO_ROOT}" oneOrMoreSubstitutedFileExists="false" # if checkout is a branch checkout if [ $3 == "1" ]; then echo "Looking for files to substitute..." repoRoot=$(git rev-parse --show-toplevel) listFilesToSubstitute=$(find -name *.gitsubstitute) for fileToSubstitute in $listFilesToSubstitute; do if ! [ -f ${fileToSubstitute%.gitsubstitute} ]; then echo "create file: ${fileToSubstitute%.gitsubstitute}" fullPath="${repoRoot}/${fileToSubstitute}" fullPathSubstitute="${repoRoot}/${fileToSubstitute%.gitsubstitute}" fileContent=$(<$fullPath) echo "${fileContent//${staticPathSubstitution}/${repoRoot}}" > "${fullPathSubstitute}" else oneOrMoreSubstitutedFileExists="true" fi done if [ $oneOrMoreSubstitutedFileExists == "true" ]; then echo "One or more substituted file exists." echo "If you want to clean the repo and recreate all projects run './clean_and_recreate_all'" fi fi