forked from diem/diem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cargo_update_outdated.sh
executable file
·31 lines (25 loc) · 902 Bytes
/
cargo_update_outdated.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Copyright (c) The Diem Core Contributors
# SPDX-License-Identifier: Apache-2.0
# This script modifies local cargo files to reflect compatibility (semver)
# upgrades to direct dependencies. It does not allow non-compatible
# updates as those should be done manually (reading the output of cargo outdated)
# It requires cargo-edit and cargo-outdated
# Example usage:
# diem$ ./scripts/cargo_update_outdated.sh
# diem$ git commit --all -m "Update dependencies"
set -e
# check install for outdated & edit
if ! $(cargo install --list | grep -qe 'cargo-outdated')
then
cargo install cargo-outdated
fi
if ! $(cargo install --list | grep -qe 'cargo-edit')
then
cargo install cargo-edit
fi
for upgrade in $(cargo outdated | awk 'NF >2 && $2 ~ /[0-9\.]+/ && $4 ~ /[0-9\.]+/ {print $1"@"$4}' | uniq |tr '\n' " ")
do
echo $upgrade
cargo -q upgrade $upgrade --all > /dev/null
done