#!/bin/bash # usage() { cat >&2 <<'END' Usage: maint/update-versions [VERSION] Updates versions to VERSION, if supplied, and then runs cargo fetch --offline # to update the lockfile maint/update-bizarre to refresh lockfiles etc. END } # We're not using cargo-edit or cargo-version because our # multi-version tests make things weird. # CARGO='nailing-cargo -u' maint/update-versions VERSION # CARGO='nailing-cargo -u' maint/update-versions set -e -o pipefail case "$#/$1" in 0/) ;; 1/0.*) ;; *) usage; exit 12;; esac version=$1 process () { perl -i~ -wpe ' use strict; my $eligible = qr{"([=^]?)(?!0\.0\.)\d+\.\d+\.\d+"}; my $new = "'"$version"'"; if (m{^version *= }) { s{$eligible}{"$1$new"}; } elsif (m{^derive-adhoc.*.*path = }) { s{\bversion *= *$eligible}{version = "$1$new"}g; } ' "$1" } if [ "x$version" != x ]; then process Cargo.toml process macros/Cargo.toml process tests/Cargo.toml process tests/pub-export/pub-a/Cargo.toml process tests/stderr/Cargo.toml fi ${CARGO-cargo} fetch maint/update-minimal-versions