Fix annoying bind; prompt for auto commit

This commit is contained in:
2021-09-15 16:14:06 +03:00
parent 9f1235ec87
commit 8ff317d0e4

View File

@@ -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;
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..."
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