From 2be8dad1ce4b7b9915488511f5c43a1ad7788f8f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Mon, 10 Dec 2018 01:06:25 +0100 Subject: [PATCH] support for git versioning of data --- clients.sh | 6 ++++++ invoices.cgi | 9 +++++++++ invoices.sh | 5 +++++ senders.sh | 6 ++++++ 4 files changed, 26 insertions(+) diff --git a/clients.sh b/clients.sh index 474f625..8e6713c 100755 --- a/clients.sh +++ b/clients.sh @@ -45,6 +45,12 @@ update_client(){ printf 'address=%s hourly=%s' \ "$(POST address |STRING)" "$(POST hourly |STRING)" \ >"clients/$id" + + [ -d .git ] && { + git add "clients/$id" + git commit -m 'Update client info for "'"$(POST address |sed 1q)"'"' -- "clients/$id" + } >/dev/null + REDIRECT "/clients/" else error Invalid Data "$id" "$(POST update)" diff --git a/invoices.cgi b/invoices.cgi index 71ab2b1..76d989a 100755 --- a/invoices.cgi +++ b/invoices.cgi @@ -35,6 +35,15 @@ tid(){ info="$(PATH "${PATH_INFO}")" +which git && [ ! -d .git ] && { + git init + mkdir -p clients/ invoices/ senders/ + printf 'export/ +serverkey' >.gitignore + git add clients/ invoices/ senders/ .gitignore + git commit -m 'initialisation of invoice repo' +} >&2 + case $info in /invoices.css) . "$_EXEC/cgilite/file.sh" diff --git a/invoices.sh b/invoices.sh index 93292cb..c21fe4f 100755 --- a/invoices.sh +++ b/invoices.sh @@ -238,6 +238,11 @@ update_invoice(){ | grep -xvF 'time= work= hours=0' done } >"invoices/$id" + + [ -d .git ] && { + git add "invoices/$id" + git commit -m 'Update invoice info for "'"$(POST number)"'"' -- "invoices/$id" + } >/dev/null fi if [ "$(POST genpdf)" ]; then read -r sender client date x<"invoices/$id" diff --git a/senders.sh b/senders.sh index 8c98737..a4ff71f 100755 --- a/senders.sh +++ b/senders.sh @@ -54,6 +54,12 @@ update_sender(){ printf 'address=%s iban=%s bic=%s\n' \ $(POST address |STRING) $(POST iban |STRING) \ $(POST bic |STRING) >"senders/$id" + + [ -d .git ] && { + git add "senders/$id" + git commit -m 'Update sender info for "'"$(POST address |sed 1q)"'"' -- "senders/$id" + } >/dev/null + REDIRECT "/senders/" else REDIRECT "/senders/$id" -- 2.39.2