diff --git a/GitUpstreamer b/GitUpstreamer index 26a16fc..57d105b 100755 --- a/GitUpstreamer +++ b/GitUpstreamer @@ -1,17 +1,22 @@ #!/bin/bash #Scripts to detect and push changes if exist; Runs in Git direcories, called by GitDaemon script. -source ~/.bash_profile > /dev/null -source ~/.zshrc > /dev/null -#Exclude directories with the .noautocommit file; -if [[ -f .autocommit ]]; then +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. Adding changes..." - 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 + 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." > /dev/null + echo "[git]: Directory has no uncommited changes." fi fi