File tree 1 file changed +50
-0
lines changed
1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ if [ " $# " -ne 1 ]; then
4
+ echo " usage: $( basename $0 ) <NEW_VERSION>" > /dev/stderr
5
+ exit 1
6
+ fi
7
+ version=$1
8
+
9
+ toml_cli=${TOML_CLI:- ${CARGO_HOME:- ~/ .cargo} / bin/ toml}
10
+ $toml_cli -h > /dev/null || {
11
+ echo " 'toml' utility not found. please run \` cargo install toml-cli\` ." > /dev/stderr
12
+ exit 1
13
+ }
14
+
15
+ # collect all .toml files for non-test/example crates
16
+ tomls=$( find -name Cargo.toml | grep -E -v ' tests/|examples/' )
17
+
18
+ # generate list of crate names (whose versions as deps we should update)
19
+ crates=$( for toml in $tomls ; do
20
+ $toml_cli get $toml package.name | tr -d \"
21
+ done)
22
+
23
+ update_key () {
24
+ toml=$1
25
+ key=$2
26
+ value=$3
27
+
28
+ old_value=$( $toml_cli get $toml $key )
29
+ # only set value if already present
30
+ if [ ! -z " $old_value " ]; then
31
+ $toml_cli set $toml $key $value | sponge $toml
32
+ fi
33
+ }
34
+
35
+ for toml in $tomls ; do
36
+ update_key $toml package.version $version
37
+ for dep_kind in dependencies build_dependencies build-dependencies dev_dependencies dev-dependencies; do
38
+ # skip if we don't have that dep kind
39
+ if [ -z " $( $toml_cli get $toml $dep_kind ) " ]; then
40
+ continue
41
+ fi
42
+ for maybe_dep in $crates ; do
43
+ dep_package=$( $toml_cli get $toml $dep_kind .$maybe_dep )
44
+ # set version if dep is present, even if version missing
45
+ if [ ! -z " $dep_package " ]; then
46
+ $toml_cli set $toml $dep_kind .$maybe_dep .version $version | sponge $toml
47
+ fi
48
+ done
49
+ done
50
+ done
You can’t perform that action at this time.
0 commit comments