Changeset View
Changeset View
Standalone View
Standalone View
contrib/source-control-tools/land-patch.sh
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
# Remove export property from CONDUIT_TOKEN so it is not accidentally logged | # Remove export property from CONDUIT_TOKEN so it is not accidentally logged | ||||
export -n CONDUIT_TOKEN | export -n CONDUIT_TOKEN | ||||
if [ -n "${REVISION}" ] && [ -z "${CONDUIT_TOKEN}" ]; then | if [ -n "${REVISION}" ] && [ -z "${CONDUIT_TOKEN}" ]; then | ||||
echo "Error: CONDUIT_TOKEN was not set" | echo "Error: CONDUIT_TOKEN was not set" | ||||
exit 10 | exit 10 | ||||
fi | fi | ||||
set -x | set -x | ||||
if [ -n "${REVISION}" ]; then | |||||
# Temporarily stop verbose logging to prevent leaking CONDUIT_TOKEN | |||||
set +x | |||||
# Fetch the revision and check its review status | |||||
REVIEW_STATUS=$(curl "https://reviews.bitcoinabc.org/api/differential.revision.search" \ | |||||
-d "api.token=${CONDUIT_TOKEN}" \ | |||||
-d "constraints[ids][0]=${REVISION:1}" |\ | |||||
jq '.result.data[].fields.status.value') || { | |||||
echo "Error: Failed to fetch review status of revision '${REVISION}'" | |||||
echo "The 'status' fields may be missing or malformed." | |||||
exit 30 | |||||
} | |||||
set -x | |||||
# We only trust code that has been accepted | |||||
if [ "${REVIEW_STATUS}" != "\"accepted\"" ]; then | |||||
echo "Error: Revision '${REVISION}' has not been accepted" | |||||
exit 31 | |||||
fi | |||||
fi | |||||
# IMPORTANT NOTE: The patch is trusted past this point. It was either reviewed | |||||
# and accepted or it was auto-generated. | |||||
TOPLEVEL=$(git rev-parse --show-toplevel) | TOPLEVEL=$(git rev-parse --show-toplevel) | ||||
DEVTOOLS_DIR="${TOPLEVEL}"/contrib/devtools | DEVTOOLS_DIR="${TOPLEVEL}"/contrib/devtools | ||||
BUILD_DIR="${TOPLEVEL}"/build | BUILD_DIR="${TOPLEVEL}"/build | ||||
mkdir -p "${BUILD_DIR}" | mkdir -p "${BUILD_DIR}" | ||||
export BUILD_DIR | export BUILD_DIR | ||||
if [ -n "${REVISION}" ]; then | if [ -n "${REVISION}" ]; then | ||||
# Pull the patch from Phabricator and rebase it on latest master | # Pull the patch from Phabricator and rebase it on latest master | ||||
Show All 24 Lines |