]> git.lizzy.rs Git - rust.git/blob - src/ci/scripts/verify-channel.sh
Rollup merge of #96478 - WaffleLapkin:rustc_default_body_unstable, r=Aaron1011
[rust.git] / src / ci / scripts / verify-channel.sh
1 #!/bin/bash
2 # We want to make sure all PRs are targeting the right branch when they're
3 # opened, otherwise we risk (for example) to land a beta-specific change to the
4 # master branch. This script ensures the branch of the PR matches the channel.
5
6 set -euo pipefail
7 IFS=$'\n\t'
8
9 source "$(cd "$(dirname "$0")" && pwd)/../shared.sh"
10
11 if isCiBranch auto || isCiBranch try || isCiBranch try-perf; then
12     echo "channel verification is only executed on PR builds"
13     exit
14 fi
15
16 channel=$(cat "$(ciCheckoutPath)/src/ci/channel")
17 case "${channel}" in
18     nightly)
19         channel_branch="master"
20         ;;
21     beta)
22         channel_branch="beta"
23         ;;
24     stable)
25         channel_branch="stable"
26         ;;
27     *)
28         echo "error: unknown channel defined in src/ci/channel: ${channel}"
29         exit 1
30 esac
31
32 branch="$(ciBaseBranch)"
33 if [[ "${branch}" != "${channel_branch}" ]]; then
34     echo "error: PRs changing the \`${channel}\` channel should be sent to the \
35 \`${channel_branch}\` branch!"
36
37     exit 1
38 fi