X-Git-Url: https://git.phdru.name/?p=cookiecutter.git;a=blobdiff_plain;f=rename-project;fp=rename-project;h=2eff036e613ca5efc286fe3be08f1563300e6f10;hp=0000000000000000000000000000000000000000;hb=66c0623a378dabb5e714afa61ec6dbc6b1bef300;hpb=bc165058ca1cfa91695b67d85a591316d14353e8 diff --git a/rename-project b/rename-project new file mode 100755 index 0000000..2eff036 --- /dev/null +++ b/rename-project @@ -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