Added script to rename the project in one command

This commit is contained in:
Georges Dupéron 2019-03-05 10:02:49 +01:00
parent 6eed11bb57
commit c87efb9b08

21
fork.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
if test $# -ne 1 || test "$1" = '-h' || test "$1" = '--help'; then
echo 'Usage: ./fork.sh name'
echo 'Renames the project'
exit 1
fi
if printf %s "$1" | grep -q -v '[-0-9a-zA-Z_ ]'; then
echo 'The name should not contain characters outside of [-0-9a-zA-Z_ ]'
echo 'TODO: escape problematic characters in the regexp and allow them'
exit 1
fi
if git grep -q -e "$1"; then
echo "The proposed name already appears in the source code."
echo "If you proceed, the new name will prevent easy renaming of this code base."
exit 1
fi
git ls-tree -r HEAD | awk '{ print $4 }' | xargs sed -i -e 's/{{{project-name}}}/'"$1"/g