#!/bin/bash #Scripts to detect and push changes if exist; Runs in Git direcories, called by GitDaemon script. source ~/.zshrc > /dev/null 2>&1 #This system is opt in; only kick in if there's a .autocommit file. if [[ -f .autocommit ]]; then if [[ -z $(git status | grep "nothing") ]]; then #If working state is not clean - assume dirty directory echo "[git]: Directory $(pwd) has changes uncommited to git." echo "Auto-Commit detected changes?" read COMMIT if [[ $COMMIT == "Y" ]] || [[ $COMMIT == "y" ]]; then git add . -A #Adds only essentials via reverse gitignore echo "[git]: Committing changes..." git commit -m "Scripted commit - $(date)" git push >/dev/null 2>&1 elif [[ $COMMIT == "N" ]] || [[ $COMMIT == "n" ]]; then echo "[git]: Ignoring changes per user request." fi elif [[ -n $(git status | grep "nothing") ]]; then echo "[git]: Directory has no uncommited changes." fi fi