2021-04-20 13:07:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
DIR="${1:-$PWD}"
|
|
|
|
|
|
|
|
echo Checking for changes in $DIR
|
|
|
|
|
|
|
|
cd $DIR
|
|
|
|
|
2021-05-11 09:42:52 +00:00
|
|
|
# add all changes (including untracked files)
|
|
|
|
git add --all .
|
2021-04-30 11:21:25 +00:00
|
|
|
|
2021-04-20 13:07:54 +00:00
|
|
|
set +e # Grep succeeds with nonzero exit codes to show results.
|
2021-04-30 11:35:06 +00:00
|
|
|
|
2021-05-20 21:08:19 +00:00
|
|
|
if git status | grep -q -E 'Changes|modified|ahead'
|
2021-04-20 13:07:54 +00:00
|
|
|
then
|
|
|
|
set -e
|
2021-04-23 06:59:06 +00:00
|
|
|
|
|
|
|
git config core.fileMode false
|
|
|
|
|
2021-05-11 09:42:52 +00:00
|
|
|
# if there are changes, commit them (needed before being able to rebase)
|
2021-06-08 14:21:51 +00:00
|
|
|
git diff-index --quiet HEAD || git commit --verbose --all || echo Skipped...
|
2021-04-23 06:59:06 +00:00
|
|
|
|
2021-06-19 14:18:23 +00:00
|
|
|
# fetch and rebase remote changes, or fallback to regular pulling if we skipped commiting
|
|
|
|
git pull --rebase || git pull
|
2021-04-23 06:59:06 +00:00
|
|
|
|
|
|
|
echo Publishing changes!
|
2021-06-08 14:21:51 +00:00
|
|
|
|
2021-04-20 13:07:54 +00:00
|
|
|
git push
|
2021-04-23 06:59:06 +00:00
|
|
|
|
2021-04-20 13:07:54 +00:00
|
|
|
else
|
|
|
|
set -e
|
2021-04-23 06:59:06 +00:00
|
|
|
#echo No local changes since last run
|
2021-06-09 11:42:40 +00:00
|
|
|
if [[ $2 == 'pull' ]]
|
2021-06-08 14:11:02 +00:00
|
|
|
then
|
|
|
|
git pull
|
|
|
|
fi
|
2021-04-20 13:07:54 +00:00
|
|
|
fi
|