Skip to content

Print version diff for rust and cargo since last rustup.sh invocaction #18485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/etc/rustup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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="https://github.com/$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="$@"
Expand Down Expand Up @@ -444,16 +480,27 @@ 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}"
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" "rust-lang/rust"
fi

if [ -z "${CFG_DISABLE_CARGO}" ]; then
Expand All @@ -469,6 +516,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" \
"rust-lang/cargo"
fi
fi

Expand Down