From 853e735edf116e8752f32b00962f3da7fffac85b Mon Sep 17 00:00:00 2001 From: Trent Nelson Date: Mon, 15 Mar 2021 12:52:57 -0600 Subject: [PATCH] Disallow version bump with dirty working tree --- scripts/increment-cargo-version.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/scripts/increment-cargo-version.sh b/scripts/increment-cargo-version.sh index 77fcb6aa0..a83d27e2b 100755 --- a/scripts/increment-cargo-version.sh +++ b/scripts/increment-cargo-version.sh @@ -105,6 +105,17 @@ check) ;; esac +# Version bumps should occur in their own commit. Disallow bumping version +# in dirty working trees. Gate after arg parsing to prevent breaking the +# `check` subcommand. +( + set +e + if ! git diff --exit-code; then + echo -e "\nError: Working tree is dirty. Commit or discard changes before bumping version." 1>&2 + exit 1 + fi +) + newVersion="$MAJOR.$MINOR.$PATCH$SPECIAL" # Update all the Cargo.toml files