summaryrefslogtreecommitdiffhomepage
path: root/scripts/setup-rust-post-checkout
diff options
context:
space:
mode:
authorLinus Färnstrand <linus@mullvad.net>2025-02-18 15:45:20 +0100
committerLinus Färnstrand <linus@mullvad.net>2025-02-18 15:45:20 +0100
commit1f9762cd1ce1172f9efc88e8394e232df14a2f9d (patch)
tree692ec6b53f78d6268c7fdb13e5f9162684511bbf /scripts/setup-rust-post-checkout
parent36e03e11c921f5c0d49c94d7fe2f272e7dafa553 (diff)
parent802570a5521d41ec9a90dae28977386a5d6cc7f9 (diff)
downloadmullvadvpn-1f9762cd1ce1172f9efc88e8394e232df14a2f9d.tar.xz
mullvadvpn-1f9762cd1ce1172f9efc88e8394e232df14a2f9d.zip
Merge branch 'add-script-and-git-hook-to-automate-installation-of-rust-droid-1786'
Diffstat (limited to 'scripts/setup-rust-post-checkout')
-rwxr-xr-xscripts/setup-rust-post-checkout28
1 files changed, 28 insertions, 0 deletions
diff --git a/scripts/setup-rust-post-checkout b/scripts/setup-rust-post-checkout
new file mode 100755
index 0000000000..ef9275f6eb
--- /dev/null
+++ b/scripts/setup-rust-post-checkout
@@ -0,0 +1,28 @@
+#!/usr/bin/env bash
+#
+# To install the hook copy this file to `.git/hooks/post-checkout` or run
+# scripts/setup-rust install_hook
+
+set -u
+
+# Set to "android", "desktop", or "ios".
+MULLVAD_SETUP_PLATFORM="${MULLVAD_SETUP_PLATFORM:-}"
+
+SETUP_RUST_SCRIPT="scripts/setup-rust"
+
+if [[ ! -f "$SETUP_RUST_SCRIPT" ]]; then
+ exit 0
+fi
+
+if [[ -z ${MULLVAD_SETUP_PLATFORM+x} ]]; then
+ echo "MULLVAD_SETUP_PLATFORM is not set, must be set to " >&2
+ echo "\`android\`, \`desktop\` or \`ios\`" >&2
+ exit 1
+fi
+
+git diff-tree --exit-code "$1".."$2" --quiet -- rust-toolchain.toml
+
+# Exit code 1 means there was a change, 0 means no change.
+if [[ $? -eq 1 ]]; then
+ $SETUP_RUST_SCRIPT "$MULLVAD_SETUP_PLATFORM"
+fi