Added script to rename the project in one command
This commit is contained in:
parent
6eed11bb57
commit
c87efb9b08
21
fork.sh
Executable file
21
fork.sh
Executable 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
|
Loading…
Reference in New Issue
Block a user