]> git.phdru.name Git - cookiecutter.git/blob - rename-project
749ad6d7a4b547de21184677e714ee84eb1cc9b3
[cookiecutter.git] / rename-project
1 #! /bin/sh
2
3 if [ -z "$2" -o -n "$3" ]; then
4    echo "Usage: $0 old_name new_name" >&2
5    exit 1
6 fi
7
8 old_name="$1"
9 new_name="$2"
10
11 fix_path() {
12    config_option="$1"
13    path="`git config --get $config_option`"
14    new_path="`echo \"$path\" | sed \"s@$old_name@$new_name@\"`"
15    git config "$config_option" "$new_path"
16 }
17
18 fix_files() {
19    replace "$old_name" "$new_name" "$@"
20 }
21
22 for project_dir in "$HOME"/prog/Python "$HOME"/current/projects \
23       "$HOME"/Internet/WWW/htdocs/git.phdru.name; do
24    cd "$project_dir" &&
25    if [ -d "$old_name" ]; then
26       mv "$old_name" "$new_name" &&
27       cd "$new_name"
28    elif [ -d "$old_name.git" ]; then
29       mv "$old_name".git "$new_name".git &&
30       cd "$new_name".git
31    else
32       continue
33    fi
34    for remote in `git remote`; do
35       fix_path "remote.$remote.url"
36    done
37    path="`git config --get --path htdocs.path`"
38    if [ -n "$path" ]; then
39       (
40          cd /home/phd/Internet/WWW/htdocs/phdru.name/Software/Python/ &&
41          if [ -d "$old_name" ]; then
42             mv "$old_name" "$new_name" &&
43             cd "$new_name" &&
44             mv "$old_name"-*.tar.bz2 "$new_name".tar.bz2 &&
45             fix_files index.tmpl
46          fi
47       ) &&
48       fix_path htdocs.path
49    fi
50    fix_files devscripts/README.html \
51       docs/conf.py docs/genapidocs docs/index.rst docs/install.rst \
52       README.rst mk-distr setup.py tox.ini
53 done