#!/bin/sh

cd ~/repos
rm -rf fca_global_api
git clone git@github.com:jdmconsulting/fca_global_api.git  >/dev/null 2>&1

cd fca_global_api/protobufSrc || exit 1

rm ~/tmp/API.html
cp ../documents/API/API.html ~/tmp/API.html

PATH=~/global-v2c-api-doc-build-script-0.0.1/protoc/bin/protoc-gen-doc:${PATH} protoc 'ls *.proto` --doc_out=../documents/templates/fca.mustache,API.html:../documents/API/ >/dev/null 2>&1

diff   ../documents/API/API.html ~/tmp/API.html 

if [ $? -eq 0 ]         # Test exit status of "cmp" command.
then 
	echo no changes >/dev/null 2>&1
else  	

	set -x

	cd ..
	git  add documents/API/API.html
	git commit -m "build API.html"
	git push

fi


cd ~/repos 
cd fca_global_api/v2mProtobufSrc || exit 1

rm ~/tmp/V2API.html
cp ../documents/V2MAPI/API.html ~/tmp/V2API.html

PATH=../../protoc-gen-doc:${PATH} protoc `ls *.proto` --doc_out=../documents/templates/fca_v2m.mustache,API.html:../documents/V2MAPI/ >/dev/null 2>&1

diff   ../documents/V2MAPI/API.html ~/tmp/V2API.html 

if [ $? -eq 0 ]         # Test exit status of "cmp" command.
then 
	echo no changes >/dev/null 2>&1
else  	

	set -x

	cd ..
	git  add documents/V2MAPI/API.html
	git commit -m "build V2MAPI.html"
	git push

fi
