From 2bbdf4f80969aced6fc5f732cce1fdb0108be7b0 Mon Sep 17 00:00:00 2001 From: Kosta Harlan Date: Mon, 2 Sep 2013 15:03:28 -0400 Subject: Initial commit --- task-git.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 task-git.sh (limited to 'task-git.sh') 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 -- cgit v1.2.1