aboutsummaryrefslogtreecommitdiff
path: root/task-git.sh
diff options
context:
space:
mode:
authorKosta Harlan <kostajh@gmail.com>2013-09-02 15:03:28 -0400
committerKosta Harlan <kostajh@gmail.com>2013-09-02 15:03:28 -0400
commit2bbdf4f80969aced6fc5f732cce1fdb0108be7b0 (patch)
tree57f2693e4e97788a71862dc3b1597a51152d8906 /task-git.sh
downloadtask-git-2bbdf4f80969aced6fc5f732cce1fdb0108be7b0.tar.xz
task-git-2bbdf4f80969aced6fc5f732cce1fdb0108be7b0.zip
Initial commit
Diffstat (limited to '')
-rwxr-xr-xtask-git.sh26
1 files changed, 26 insertions, 0 deletions
diff --git a/task-git.sh b/task-git.sh
new file mode 100755
index 0000000..24b9f9c
--- /dev/null
+++ b/task-git.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+# Get task command
+TASK_COMMAND="task ${@}"
+# Get data dir
+DATA_RC=$(task _show | grep data.location)
+DATA=(${DATA_RC//=/ })
+DATA_DIR=${DATA[1]}
+if [ ! -d "$DATA_DIR" ]; then
+ echo 'Could not load data directory!'
+ exit 1
+fi
+# The backup directory is stored alongside the existing data directory.
+BACKUP_DIR="${DATA_DIR}.bak"
+# Create backups
+DATA_DIR_FILES="${DATA_DIR}/*"
+mkdir -p $BACKUP_DIR
+cp -R $DATA_DIR_FILES "${BACKUP_DIR}/"
+cd $BACKUP_DIR
+git add .
+git commit -m "$TASK_COMMAND" > /dev/null
+/usr/bin/task $@
+cp -R $DATA_DIR_FILES "${BACKUP_DIR}/"
+git add .
+git commit -m "$TASK_COMMAND" > /dev/null
+exit 0