From: Ian Jackson Date: Sun, 18 Apr 2021 18:26:20 +0000 (+0100) Subject: update-version: New maintenance script X-Git-Tag: otter-0.5.0~16 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=0d011a4be65392354cc86c39e881a601178917b9;p=otter.git update-version: New maintenance script Signed-off-by: Ian Jackson --- diff --git a/update-versions b/update-versions new file mode 100755 index 00000000..c017e2c3 --- /dev/null +++ b/update-versions @@ -0,0 +1,39 @@ +#!/bin/bash +# usage: +# ./update-versions [--all-meta] 0.5.0 + +set -e + +fail () { echo >&2 "${0##*/}: error: $*"; exit 12; } + +case "$1" in +-*) fail "unknown option $1" ;; +esac + +version="$1" +case "$version" in +'') fail 'need new version number' ;; +*[^0-9.]*) fail 'version number contains bad character' ;; +[^0-9]*) fail 'version number starts with non-digit' ;; +esac + +files=$(git ls-files :\*/Cargo.toml :Cargo.toml) +dirty=$(git status -u --porcelain $files) + +if [ "x$dirty" != x ]; then + printf >&2 "%s\n" "$dirty" + fail 'some Cargo.toml[s] are dirty.' +fi + +for f in $files; do + perl -i~ -pe ' + next unless m{^\[package\]\s*$}...m{^\[}; + $y=1 if s{^version=".*}{version="'$version'"}; + END { $y or die "appropriate line not found in '$f'" } + ' "$f" +done + +git commit -s -m "Cargo.toml: Update all versions to $version + +Commit made automatically by update-versions. +" $files