diff options
Diffstat (limited to 'task-git.sh')
-rwxr-xr-x | task-git.sh | 46 |
1 files changed, 13 insertions, 33 deletions
diff --git a/task-git.sh b/task-git.sh index db5df12..1962658 100755 --- a/task-git.sh +++ b/task-git.sh @@ -13,6 +13,14 @@ DATA_DIR=${DATA[1]} # Need to expand home dir ~ eval DATA_DIR=$DATA_DIR +# Function for make a commit +make_commit() { + git add . > $LOGFILE + git commit -m "$TASK_COMMAND" > $LOGFILE + echo "Committed" +} + + # Exit if we don't have a tasks data directory if [ ! -e "$DATA_DIR" ]; then echo "Could not load data directory $DATA_DIR." @@ -30,28 +38,21 @@ if ! [ -d "$DATA_DIR/.git" ]; then fi # Push by default -PUSH=1 +PUSH=0 PULL=0 +COMMIT=0 -# Check if --no-push is passed as an argument. -for i in $@ -do - if [ "$i" == "--no-push" ]; then - # Set the PUSH flag, and remove this from the arguments list. - PUSH=0 - shift - fi -done # Check if we are passing something that doesn't do any modifications for i in $1 do case $i in - append|completed|delete|done|due|duplicate|edit|end|modify|prepend|rm|start|stop) - echo "Push" + add|append|completed|delete|done|due|duplicate|edit|end|modify|prepend|rm|start|stop) + make_commit ;; push) echo "Push" + PUSH=1 ;; pull) echo "Pull" @@ -63,23 +64,6 @@ do esac done -# Check if we are passing a command for the second arg (filter for the first) -if [ $PUSH -eq 0 ] -then - for i in $2 - do - case $i in - add|append|completed|delete|done|due|duplicate|edit|end|modify|prepend|rm|start|stop) - PUSH=1 - echo "Push" - ;; - *) - ;; - esac - done -fi - - pushd $DATA_DIR > $LOGFILE # Check if we have a place to push to @@ -89,16 +73,12 @@ if [ -z $GIT_REMOTE ]; then PUSH=0 fi - if [ "$PULL" == 1 ]; then echo "Fetching & Applying updates from $GIT_REMOTE" git fetch && git pull exit 0 fi -# Add to git -git add . > $LOGFILE -git commit -m "$TASK_COMMAND" > $LOGFILE # Push if [ "$PUSH" == 1 ]; then |