]> git.phdru.name Git - cookiecutter.git/blobdiff - rename-project
Add scripts for manipulating projects
[cookiecutter.git] / rename-project
diff --git a/rename-project b/rename-project
new file mode 100755 (executable)
index 0000000..2eff036
--- /dev/null
@@ -0,0 +1,53 @@
+#! /bin/sh
+
+if [ -z "$2" -o -n "$3" ]; then
+   echo "Usage: $0 old_name new_name" >&2
+   exit 1
+fi
+
+old_name="$1"
+new_name="$2"
+
+fix_path() {
+   config_option="$1"
+   path="`git config --get $config_option`"
+   new_path="`echo \"$path\" | sed \"s@$old_name@$new_name@\"`"
+   git config "$config_option" "$new_path"
+}
+
+fix_files() {
+   replace "$old_name" "$new_name" "$@"
+}
+
+for project_dir in "$HOME"/prog/Python "$HOME"/current/projects \
+      "$HOME"/Internet/WWW/htdocs/git.phdru.name; do
+   cd "$project_dir" &&
+   if [ -d "$old_name" ]; then
+      mv "$old_name" "$new_name" &&
+      cd "$new_name"
+   elif [ -d "$old_name.git" ]; then
+      mv "$old_name".git "$new_name".git &&
+      cd "$new_name".git
+   else
+      continue
+   fi
+   for remote in `git remote`; do
+      fix_path "remote.$remote.url"
+   done
+   path="`git config --get --path htdocs.path`"
+   if [ -n "$path" ]; then
+      (
+         cd /home/phd/Internet/WWW/htdocs/phdru.name/Software/Python/ &&
+         if [ -d "$old_name" ]; then
+            mv "$old_name" "$new_name" &&
+            cd "$new_name" &&
+            mv "$old_name"-*.tar.bz2 "$new_name".tar.bz2 &&
+            fix_files index.tmpl
+         fi
+      ) &&
+      fix_path htdocs.path
+   fi
+   fix_files devscripts/README.html \
+      docs/conf.py docs/genapidocs docs/index.rst docs/install.rst \
+      README.txt mk-distr setup.py tox.ini
+done