Changeset View
Changeset View
Standalone View
Standalone View
contrib/source-control-tools/automated-commits.sh
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
done | done | ||||
: "${COMMIT_TYPE:=}" | : "${COMMIT_TYPE:=}" | ||||
if [ -z "${COMMIT_TYPE}" ]; then | if [ -z "${COMMIT_TYPE}" ]; then | ||||
echo "Error: Environment variable COMMIT_TYPE must be set" | echo "Error: Environment variable COMMIT_TYPE must be set" | ||||
exit 2 | exit 2 | ||||
fi | fi | ||||
GIT_PUSH_OPTIONS=("--verbose") | LAND_PATCH_ARGS=() | ||||
case ${DRY_RUN:=yes} in | case ${DRY_RUN:=yes} in | ||||
no|NO|false|FALSE) | no|NO|false|FALSE) | ||||
if [ "${PARENT_COMMIT}" != "${DEFAULT_PARENT_COMMIT}" ]; then | if [ "${PARENT_COMMIT}" != "${DEFAULT_PARENT_COMMIT}" ]; then | ||||
echo "Error: Running with DRY_RUN=no on a commit parent other than '${DEFAULT_PARENT_COMMIT}'" | echo "Error: Running with DRY_RUN=no on a commit parent other than '${DEFAULT_PARENT_COMMIT}'" | ||||
exit 3 | exit 3 | ||||
fi | fi | ||||
;; | ;; | ||||
*) | *) | ||||
GIT_PUSH_OPTIONS+=("--dry-run") | LAND_PATCH_ARGS+=("--dry-run") | ||||
;; | ;; | ||||
esac | esac | ||||
echo "Building automated commit '${COMMIT_TYPE}'..." | echo "Building automated commit '${COMMIT_TYPE}'..." | ||||
BOT_PREFIX="[Automated]" | BOT_PREFIX="[Automated]" | ||||
TOPLEVEL=$(git rev-parse --show-toplevel) | TOPLEVEL=$(git rev-parse --show-toplevel) | ||||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Lines | update-timings) | ||||
;; | ;; | ||||
*) | *) | ||||
echo "Error: Invalid commit name '${COMMIT_TYPE}'" | echo "Error: Invalid commit name '${COMMIT_TYPE}'" | ||||
exit 10 | exit 10 | ||||
;; | ;; | ||||
esac | esac | ||||
# Smoke tests to give some confidence that master won't be put into a bad state | # Land the generated commit | ||||
"${DEVTOOLS_DIR}"/smoke-tests.sh | "${TOPLEVEL}"/contrib/source-control-tools/land-patch.sh "${LAND_PATCH_ARGS[@]}" | ||||
echo "Pushing automated commit '${COMMIT_TYPE}'..." | |||||
# Make sure master is up-to-date. If there is a merge conflict, this script | |||||
# will not attempt to resolve it and simply fail. | |||||
git fetch origin master | |||||
git rebase "${PARENT_COMMIT}" | |||||
git push "${GIT_PUSH_OPTIONS[@]}" origin master |