summaryrefslogtreecommitdiffstats
path: root/src/ci/scripts/verify-channel.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /src/ci/scripts/verify-channel.sh
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/ci/scripts/verify-channel.sh')
-rwxr-xr-xsrc/ci/scripts/verify-channel.sh38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/ci/scripts/verify-channel.sh b/src/ci/scripts/verify-channel.sh
new file mode 100755
index 000000000..cd28748a4
--- /dev/null
+++ b/src/ci/scripts/verify-channel.sh
@@ -0,0 +1,38 @@
+#!/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"
+
+if isCiBranch auto || isCiBranch try || isCiBranch try-perf; then
+ echo "channel verification is only executed on PR builds"
+ exit
+fi
+
+channel=$(cat "$(ciCheckoutPath)/src/ci/channel")
+case "${channel}" in
+ nightly)
+ channel_branch="master"
+ ;;
+ beta)
+ channel_branch="beta"
+ ;;
+ stable)
+ channel_branch="stable"
+ ;;
+ *)
+ echo "error: unknown channel defined in src/ci/channel: ${channel}"
+ exit 1
+esac
+
+branch="$(ciBaseBranch)"
+if [[ "${branch}" != "${channel_branch}" ]]; then
+ echo "error: PRs changing the \`${channel}\` channel should be sent to the \
+\`${channel_branch}\` branch!"
+
+ exit 1
+fi