|
|
@ -0,0 +1,25 @@ |
|
|
|
#!/bin/bash |
|
|
|
|
|
|
|
repoRoot=$(git rev-parse --show-toplevel) |
|
|
|
listStaticPathFiles=$(git grep -lr --untracked $repoRoot) |
|
|
|
listStagedFiles=$(git diff --staged --name-only) |
|
|
|
|
|
|
|
staticPathSubstitution="\${REPO_ROOT}" |
|
|
|
|
|
|
|
for entryStagedFile in $listStagedFiles; do |
|
|
|
for entryStaticPathFile in $listStaticPathFiles; do |
|
|
|
if [ $entryStagedFile == $entryStaticPathFile ]; then |
|
|
|
fullPath="${repoRoot}/${entryStagedFile}" |
|
|
|
entryStagedFileSubstitute="${entryStagedFile}.gitsubstitute" |
|
|
|
fullPathSubstitute="${repoRoot}/${entryStagedFileSubstitute}" |
|
|
|
|
|
|
|
rm -f $fullPathSubstitute |
|
|
|
|
|
|
|
fileContent=$(<$fullPath) |
|
|
|
echo "${fileContent//${repoRoot}/${staticPathSubstitution}}" > "${fullPathSubstitute}" |
|
|
|
|
|
|
|
git rm --cached $entryStagedFile |
|
|
|
git add -f $entryStagedFileSubstitute |
|
|
|
fi |
|
|
|
done |
|
|
|
done |