aboutsummaryrefslogtreecommitdiffstats
path: root/copydb-current-branch
diff options
context:
space:
mode:
authorGravatar Tom Willemse2014-03-10 20:32:10 +0100
committerGravatar Tom Willemse2014-03-10 20:32:10 +0100
commit2cd07d308c7a218bba0e321fa59f3d54d5c522ef (patch)
tree5bac478bb2e25e630ba1a0846d4fe07797db0f72 /copydb-current-branch
downloaddb-utilities-2cd07d308c7a218bba0e321fa59f3d54d5c522ef.tar.gz
db-utilities-2cd07d308c7a218bba0e321fa59f3d54d5c522ef.zip
Initial commit
Diffstat (limited to 'copydb-current-branch')
-rwxr-xr-xcopydb-current-branch28
1 files changed, 28 insertions, 0 deletions
diff --git a/copydb-current-branch b/copydb-current-branch
new file mode 100755
index 0000000..1228941
--- /dev/null
+++ b/copydb-current-branch
@@ -0,0 +1,28 @@
+#!/usr/bin/zsh
+## copydb-current-branch --- Create a copy of a database for the current branch
+
+## Commentary:
+
+# Use `copydb' to create a copy of the database named after the
+# current branch. This requires the current working directory to be a
+# git repository. The name of the database is created by substituting
+# all occurrences of `-' with `_'. The database copied from is always
+# called `aeos_babel'. The database copied to is called
+# `aeos_<branchname>'.
+
+# This program is just a wrapper for `copydb', so all information
+# related to it is also relevant, please read its comments for more
+# info.
+
+# Usage is:
+
+# copydb-current-branch
+
+## Code:
+
+base="aeos_babel"
+branch=$(git branch --no-color | grep '*' | sed -e 's/* //' -e 's/-/_/g')
+nbranch="aeos_${branch}"
+
+echo Copying "$base" to "$nbranch"
+copydb "$base" "$nbranch"