diff options
| author | Pietro Albini <pietro@pietroalbini.org> | 2021-05-06 18:47:37 +0200 |
|---|---|---|
| committer | Pietro Albini <pietro@pietroalbini.org> | 2021-05-06 18:47:37 +0200 |
| commit | 392723ec6e643f694a66e47941e5c8ae670e219f (patch) | |
| tree | ab59af1a27c5db07b737e442205c8702188edcd1 /src/ci/scripts | |
| parent | 81a97cea83a34dfaf214a66d213dd0d02a495cbd (diff) | |
| download | rust-392723ec6e643f694a66e47941e5c8ae670e219f.tar.gz rust-392723ec6e643f694a66e47941e5c8ae670e219f.zip | |
ci: error out if someone sends a PR to the wrong branch
Diffstat (limited to 'src/ci/scripts')
| -rwxr-xr-x | src/ci/scripts/verify-channel.sh | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/ci/scripts/verify-channel.sh b/src/ci/scripts/verify-channel.sh new file mode 100755 index 00000000000..7945512738e --- /dev/null +++ b/src/ci/scripts/verify-channel.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# We want to make sure all PRs are targeting the right branch when they're +# opened, otherwise we risk (for example) to land a beta-specific change to the +# master branch. This script ensures the branch of the PR matches the channel. + +set -euo pipefail +IFS=$'\n\t' + +source "$(cd "$(dirname "$0")" && pwd)/../shared.sh" + +declare -A CHANNEL_BRANCH +CHANNEL_BRANCH["nightly"]="master" +CHANNEL_BRANCH["beta"]="beta" +CHANNEL_BRANCH["stable"]="stable" + +if isCiBranch auto || isCiBranch try; then + echo "channel verification is only executed on PR builds" + exit +fi + +channel=$(cat "$(ciCheckoutPath)/src/ci/channel") +branch="$(ciBaseBranch)" +if [[ "${branch}" != "${CHANNEL_BRANCH[$channel]}" ]]; then + echo "error: PRs changing the \`${channel}\` channel should be sent to the \ +\`${CHANNEL_BRANCH[$channel]}\` branch!" + + exit 1 +fi |
