Imported Git auto-commit scripts from work with mild changes
This commit is contained in:
11
GitDaemon
Executable file
11
GitDaemon
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#small script to be appended to bash.profile; calls the GitUpstreamer script to auto-commit changes
|
||||||
|
function cd {
|
||||||
|
# Actually change the directory with all args passed to the function
|
||||||
|
if builtin cd "$@"; then
|
||||||
|
# If the dir exists, run the git script on git directories
|
||||||
|
if [[ -d ".git" ]] ; then
|
||||||
|
echo "[git]: Note $(pwd) is under Git revision control."
|
||||||
|
. "$SCRIPTS/GitUpstreamer"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
17
GitUpstreamer
Executable file
17
GitUpstreamer
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/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
|
||||||
|
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
|
||||||
|
elif [[ -n $(git status | grep "nothing") ]]; then
|
||||||
|
echo "[git]: Directory has no uncommited changes." > /dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user