bonfire-app/git-publish.sh
2021-06-08 13:48:06 +02:00

33 lines
631 B
Bash
Executable file

#!/bin/bash
DIR="${1:-$PWD}"
echo Checking for changes in $DIR
cd $DIR
# add all changes (including untracked files)
git add --all .
set +e # Grep succeeds with nonzero exit codes to show results.
if git status | grep -q -E 'Changes|modified|ahead'
then
set -e
git config core.fileMode false
# if there are changes, commit them (needed before being able to rebase)
git diff-index --quiet HEAD || git commit --verbose --all
# fetch and rebase remote changes
git pull --rebase
echo Publishing changes!
git push
else
set -e
#echo No local changes since last run
#git pull
fi