From c87efb9b08f432d1ccb1598863c47f8213b5ab5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Georges=20Dup=C3=A9ron?= Date: Tue, 5 Mar 2019 10:02:49 +0100 Subject: [PATCH] Added script to rename the project in one command --- fork.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 fork.sh diff --git a/fork.sh b/fork.sh new file mode 100755 index 0000000..a276ddf --- /dev/null +++ b/fork.sh @@ -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