From a193cab9c5fb4d14c85b0e0d868ba9eb55de7ccd Mon Sep 17 00:00:00 2001 From: Ben Savage Date: Mon, 5 Jul 2021 21:31:13 +1000 Subject: [PATCH] fixing git behaviour and making it quiet --- cl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/cl b/cl index 53e3da1..8fd6a10 100755 --- a/cl +++ b/cl @@ -121,7 +121,7 @@ function captains_log() { TODAY=$(date +%F) TOMORROW=$(date +%F -d "+${modT:-1} day") - if [ ${GIT:-1} ] && [ -f "$CLDIR/.git" ]; then + if [ ${GIT:-1} ] && [ -d "$CLDIR/.git" ]; then GIT=1 else GIT=0 @@ -131,8 +131,8 @@ function captains_log() { mkdir "$CLDIR" fi - if [ $GIT ]; then - git -C "$CLDIR" pull & + if [ $GIT -ne 0 ]; then + git -C "$CLDIR" pull -q & fi @@ -148,7 +148,7 @@ function captains_log() { "$CLDIR/template" > $CLDIR/${!i} elif [ -f "$CLDIR/template" ]; then DATE_ARGS="$(grep '{{DATE[^}]*}}' "$CLDIR/template"|tr -d {}|cut -d' ' -f2-)" - if [ "$DATE_ARGS" == '' ]; then DATE_ARGS='%A %d %B %Y'; fi + if [ "$DATE_ARGS" == 'DATE' ]; then DATE_ARGS='%A %d %B %Y'; fi debug "From static template with DATE_ARGS=$DATE_ARGS" sed "s/{{DATE[^}]*}}/$(date "+$DATE_ARGS" -d ${!i})/g" $CLDIR/template > $CLDIR/${!i} else @@ -195,11 +195,12 @@ function captains_log() { vi -O $CLDIR/{$YESTERDAY,$TODAY,$TOMORROW} - if [ $GIT ]; then + if [ $GIT -ne 0 ]; then + echo Updating git... if [ $( git -C "$CLDIR" status -s |wc -l) -ne 0 ]; then - git -C "$CLDIR" add -A - git -C "$CLDIR" commit -m "Audo-Commit by $(basename $0)" - git -C "$CLDIR" push + git -C "$CLDIR" add -Aq + git -C "$CLDIR" commit -qm "Auto-Commit by $(basename $0)" + git -C "$CLDIR" push -q fi fi }