Feat: Add script for moving projects
authorOleg Broytman <phd@phdru.name>
Fri, 15 Jun 2018 16:34:56 +0000 (19:34 +0300)
committerOleg Broytman <phd@phdru.name>
Fri, 15 Jun 2018 16:34:56 +0000 (19:34 +0300)
move-project [new file with mode: 0755]

diff --git a/move-project b/move-project
new file mode 100755 (executable)
index 0000000..72f7475
--- /dev/null
@@ -0,0 +1,27 @@
+#! /bin/sh
+
+if [ -z "$1" -o -n "$2" ]; then
+   echo "Usage: $0 project_name" >&2
+   exit 1
+fi
+
+project_name="$1"
+old_dir="$HOME/admin/prog/$1"
+new_dir="$HOME/prog/Python/$1"
+
+fix_path() {
+   config_option="$1"
+   path="`git config --get $config_option`"
+   new_path="`echo \"$path\" | sed \"s@$old_dir@$new_dir@\"`"
+   git config "$config_option" "$new_path"
+}
+
+mv "$old_dir" "$new_dir" &&
+
+for project_dir in "$new_dir" "$HOME"/current/projects/"$project_name" \
+      "$HOME"/Internet/WWW/htdocs/git.phdru.name/"$project_name".git; do
+   cd "$project_dir" &&
+   for remote in `git remote`; do
+      fix_path "remote.$remote.url"
+   done
+done