2016-11-18 22:05:49 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
2023-09-14 08:29:08 +00:00
|
|
|
set -x
|
2016-11-18 22:05:49 +00:00
|
|
|
|
2019-11-23 14:18:23 +00:00
|
|
|
PRODUCTION_BRANCH="${PRODUCTION_BRANCH:-master}"
|
2016-11-18 22:05:49 +00:00
|
|
|
|
|
|
|
git_rev_name() {
|
|
|
|
git rev-parse --abbrev-ref --symbolic-full-name "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
# If the checkout is not on the production branch,
|
|
|
|
# assume maintenance is happening and stop.
|
|
|
|
if [ "$(git_rev_name HEAD)" != "$PRODUCTION_BRANCH" ]; then
|
2019-11-23 14:12:12 +00:00
|
|
|
exit 0
|
2016-11-18 22:05:49 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Abort if the production branch isn't tracking a remote branch.
|
|
|
|
if ! git_upstream="$(git_rev_name '@{upstream}' 2>/dev/null)"; then
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
|
|
|
|
IFS=/ read git_remote git_refspec <<EOF
|
|
|
|
$git_upstream
|
|
|
|
EOF
|
2023-09-14 08:34:53 +00:00
|
|
|
git fetch --quiet --no-tags "$git_remote" "$git_refspec"
|
2016-11-18 22:05:49 +00:00
|
|
|
if [ "$(git rev-parse "$PRODUCTION_BRANCH")" = "$(git rev-parse "$git_upstream")" ]; then
|
2019-11-23 14:12:12 +00:00
|
|
|
exit 0
|
2016-11-18 22:05:49 +00:00
|
|
|
fi
|
|
|
|
|
2019-11-23 14:12:12 +00:00
|
|
|
exitcode=0
|
2023-09-14 08:34:53 +00:00
|
|
|
git merge --quiet --ff-only "${git_remote}/${git_refspec}"
|
2023-10-25 11:56:44 +00:00
|
|
|
python3 -m compileall -q -x - conservancy || exitcode=$?
|
|
|
|
chgrp -R www-data conservancy || exitcode=$?
|
|
|
|
chmod -R g+rX-w,o+X-w conservancy || exitcode=$?
|
|
|
|
chmod -R o+r conservancy/static || exitcode=$?
|
2016-11-18 22:05:49 +00:00
|
|
|
exit "$exitcode"
|