Last active
August 29, 2015 14:07
-
-
Save jakerr/ff947ac75196f5cb2032 to your computer and use it in GitHub Desktop.
rustup diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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-lang/rust@dc987ad...b5ba2f5