#!/bin/bash
if [[ $1 == "commit" ]]; then
	mv $GVM_ROOT/git.bak $GVM_ROOT/.git
  if [ $? -ne 0 ]; then
    echo "Couldn't find git info"
    exit 1
  fi
  if [[ -n $2 ]]; then
		cd $GVM_ROOT && git add . && git commit -m "$2"
		if [ $? -ne 0 ]; then
		  echo "Failed to commit"
		  exit 1
		fi
	fi
	cd $GVM_ROOT && git push
  if [ $? -ne 0 ]; then
    echo "Failed to push"
    exit 1
  fi
	mv $GVM_ROOT/.git $GVM_ROOT/git.bak
  if [ $? -ne 0 ]; then
    echo "Couldn't backup git info"
    exit 1
  fi
else
  echo "Please use gvm [action] to call this file"
  exit 1
fi

