]> git.plutz.net Git - invoices/commitdiff
support for git versioning of data
authorPaul Hänsch <paul@plutz.net>
Mon, 10 Dec 2018 00:06:25 +0000 (01:06 +0100)
committerPaul Hänsch <paul@plutz.net>
Mon, 10 Dec 2018 00:06:25 +0000 (01:06 +0100)
clients.sh
invoices.cgi
invoices.sh
senders.sh

index 474f6258538189525f60dea9dff0d2eb40f96301..8e6713c4bf5c4753dcb7768d0a21fa5356a81481 100755 (executable)
@@ -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)"
index 71ab2b1e79a6aa540ec0167c3648ba4e4e7b725e..76d989a0dffbee3c28ebb490dafcdba04c15d8c3 100755 (executable)
@@ -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"
index 93292cbee74a31f0b69613940c8a4bc72b215712..c21fe4fe3b597c8cf42b31ca570d1813ea653498 100755 (executable)
@@ -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"
index 8c98737a39b4195ad681172777eb734753fffb87..a4ff71f171ed3e1bd05f49956eaa7f37ca61a925 100755 (executable)
@@ -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"