Skip to content

Instantly share code, notes, and snippets.

@smoelius
Created August 31, 2021 23:12
Show Gist options
  • Save smoelius/02c63fa0aa33d1f2bc913c8008890d45 to your computer and use it in GitHub Desktop.
Save smoelius/02c63fa0aa33d1f2bc913c8008890d45 to your computer and use it in GitHub Desktop.
A Bash script to update Clippy's dependencies within the Rust repository
#! /bin/bash
set -euo pipefail
if [[ ! -d src/tools/clippy ]]; then
echo "$0 must be run from the root of the rust repository." >&2
exit 1
fi
RUST="$PWD"
REMOVE_PATCH_VERSION='s/\(= "[[:digit:]]\+\.[[:digit:]]\+\)\.[[:digit:]]\+\("\)/\1\2/'
# Make cargo-upgrade think clippy is in its own workspace.
pushd "$(mktemp -d)"
ln -s "$RUST/src/tools/clippy"
# Run cargo-upgrade.
find -H clippy -name Cargo.toml -not -path "clippy/tests/*" \
-exec cargo upgrade --workspace --manifest-path={} \;
# Remove patch versions.
find -H clippy -name Cargo.toml -not -path 'clippy/tests/*' \
-exec sed -i "/^\[dependencies\]$/,$ $REMOVE_PATCH_VERSION" {} \;
popd
# Update lockfile.
cargo update -p clippy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment