Skip to content

Instantly share code, notes, and snippets.

@lanzafame
Forked from unode/taskgit
Created October 29, 2015 04:47
Show Gist options
  • Save lanzafame/c9a974d69139592f1a8e to your computer and use it in GitHub Desktop.
Save lanzafame/c9a974d69139592f1a8e to your computer and use it in GitHub Desktop.
#!/bin/sh
# copyright 2014 Renato Alves
# distributed under the GPL licence
if [ -z "$TASKDIR" ]; then
#TODO Look for data location in rc:location instead of assuming ~/.taskrc
TASKDIR="$(grep data.location $HOME/.taskrc | cut -d '=' -f 2)"
fi
if [ -z "$TASKBIN" ]; then
TASKBIN="task"
fi
$TASKBIN "$@"
EXITCODE="$?"
if [ -d "$TASKDIR" ]; then
cd "$TASKDIR"
else
echo "Couldn't navigate to TASKDIR: $TASKDIR"
exit $EXITCODE
fi
if ! [ -d "$TASKDIR/.git" ]; then
git init 2>&1 > git.log
echo "git.log" > .gitignore
echo "git.log.old" >> .gitignore
echo "*.pem" >> .gitignore
git add .gitignore 2>&1 >> git.log
git add *.data *.theme 2>&1 >> git.log
git commit -a -m "Initial log" 2>&1 >> git.log
fi
if [ "$#" -gt "0" ]; then
git add *.data *.theme 2>&1 >> git.log
git commit -a -m "$*" 2>&1 >> git.log
fi
# Rotate git.log if bigger than 1M
if [ "$(stat -c '%s' git.log)" -gt "1000000" ]; then
mv -f git.log git.log.old
touch git.log
fi
exit $EXITCODE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment