Skip to content

Instantly share code, notes, and snippets.

@jakerr
Last active August 29, 2015 14:07
Show Gist options
  • Save jakerr/ff947ac75196f5cb2032 to your computer and use it in GitHub Desktop.
Save jakerr/ff947ac75196f5cb2032 to your computer and use it in GitHub Desktop.
rustup diff
diff --git a/rustup.sh b/rustup.sh
index 62a2b35..9350e55 100755
--- a/rustup.sh
+++ b/rustup.sh
@@ -231,6 +231,42 @@ validate_opt () {
probe_need CFG_CURL curl
+version() {
+ local bin_dir=$1
+ local bin=$2
+ local arg=
+ if [ "$bin" = "cargo" ]
+ then
+ arg="version"
+ else
+ arg="--version"
+ fi
+ echo $($bin_dir/$bin $arg 2>&1)
+}
+
+version_revision() {
+ local vers=$1
+ echo $(echo "$vers" |sed -E "s/[^(]+\(([^ ]+).*/\1/")
+}
+
+print_version_diff() {
+ local prev=$1
+ local cur=$2
+ local upstream=$3
+ if [ "$prev" = "$cur" ]
+ then
+ echo " Version was the same"
+ else
+ echo " Went from version:"
+ echo " $prev"
+ echo " to"
+ echo " $cur"
+ local v1=$(version_revision "$prev")
+ local v2=$(version_revision "$cur")
+ echo " See diff here: ${upstream}/compare/${v1}...${v2}"
+ fi
+}
+
CFG_SRC_DIR="$(cd $(dirname $0) && pwd)/"
CFG_SELF="$0"
CFG_ARGS="$@"
@@ -443,9 +479,16 @@ then
fi
MAYBE_PREFIX=
+BIN_DIR="/usr/local/bin"
if [ -n "${CFG_PREFIX}" ]
then
MAYBE_PREFIX="--prefix=${CFG_PREFIX}"
+ BIN_DIR="${CFG_PREFIX}/bin"
+fi
+
+PREV_VERS=$(version "$BIN_DIR" rustc)
+if [ -z "${CFG_DISABLE_CARGO}" ]; then
+ PREV_CARGO_VERS=$(version "$BIN_DIR" cargo)
fi
sh "${LOCAL_INSTALL_SCRIPT}" "${MAYBE_UNINSTALL}" "${MAYBE_PREFIX}"
@@ -453,6 +496,10 @@ if [ $? -ne 0 ]
then
rm -Rf "${TMP_DIR}"
err "failed to install Rust"
+elif [ -n "${PREV_VERS}" ]
+then
+ VERS=$(version "$BIN_DIR" rustc)
+ print_version_diff "$PREV_VERS" "$VERS" "https://github.com/rust-lang/rust"
fi
if [ -z "${CFG_DISABLE_CARGO}" ]; then
@@ -468,6 +515,12 @@ if [ -z "${CFG_DISABLE_CARGO}" ]; then
then
rm -Rf "${TMP_DIR}"
err "failed to install Cargo"
+ elif [ -n "${PREV_CARGO_VERS}" ]
+ then
+ CARGO_VERS=$(version "$BIN_DIR" cargo)
+ print_version_diff "$PREV_CARGO_VERS" \
+ "$CARGO_VERS" \
+ "https://github.com/rust-lang/cargo"
fi
fi
@jakerr
Copy link
Author

jakerr commented Oct 5, 2014

Don't know where the source to rustup.sh lives but wanted to share this useful patch.

It will print a message saying what version you changed from and to and gives a github link to the comparison between the previous and current version.

e.g.

Rust is ready to roll.

Went from version:
rustc 0.12.0-nightly (dc987adfc 2014-10-04 23:42:07 +0000)
to
rustc 0.12.0-nightly (b5ba2f551 2014-10-06 20:27:14 +0000)
See diff here: https://github.com/rust-lang/rust/compare/dc987adfc...b5ba2f551

rust-lang/rust@dc987ad...b5ba2f5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment