aboutsummaryrefslogtreecommitdiffstats
path: root/copydb-current-branch
diff options
context:
space:
mode:
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"