Begin watching git's status too, not just the grep status of not already being up to date. Add more conditional branches so that errors are logged properly.

This commit is contained in:
2025-10-14 13:37:55 -07:00
parent 7379df38de
commit 6e3666cea2

View File

@@ -27,14 +27,24 @@ function reload-project {
## Main ##
# Pull any updates, and if the project is already up to date, exit successfully.
git pull | grep -v "up to date"
status="$?"
log "Pull status is '$status'."
if [[ $status != 0 ]]; then
output="`git pull`"
git_status="$?"
echo "$output" | grep -v "up to date"
grep_status="$?"
log "Pull status is '$git_status', anything but 'up to date' is '$grep_status'."
if [[ $git_status != 0 ]]; then
log "*** ERROR: Git reported a failure! ***"
exit 1
elif [[ $git_status == 0 && $grep_status == 0 ]]; then
reload-project
elif [[ $git_status == 0 && $grep_status != 0 ]]; then
log "Site is already up to date, exiting."
exit 0
else
reload-project
log "*** WARNING: Unknown Situation ***"
fi
exit 0