From 3f3f3bb443ed6e295bb10d42a67731aa3ac74328 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Tue, 16 Mar 2021 01:58:15 +0000 Subject: [PATCH] increment_cargo_version.sh tune ups (bp #15880) (#15891) * Disallow version bump with dirty working tree (cherry picked from commit 853e735edf116e8752f32b00962f3da7fffac85b) * Ignore `not_paths` for `*.md` files when bumping version (cherry picked from commit 510760d81b5d6ce79f27ade56baa4e6c0ef4f099) * Also ignore `*/node_modules/*` paths when bumping version (cherry picked from commit 2bf46b789fa35ad69aa25eee5fde7093604a5372) Co-authored-by: Trent Nelson --- scripts/increment-cargo-version.sh | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/scripts/increment-cargo-version.sh b/scripts/increment-cargo-version.sh index 77fcb6aa09..96f223936b 100755 --- a/scripts/increment-cargo-version.sh +++ b/scripts/increment-cargo-version.sh @@ -23,6 +23,7 @@ ignores=( .cargo target web3.js/examples + node_modules ) not_paths=() @@ -30,10 +31,10 @@ for ignore in "${ignores[@]}"; do not_paths+=(-not -path "*/$ignore/*") done -# shellcheck disable=2207,SC2068 # Don't want a positional arg if `not-paths` is empty -Cargo_tomls=($(find . -mindepth 2 -name Cargo.toml ${not_paths[@]})) # shellcheck disable=2207 -markdownFiles=($(find . -name "*.md")) +Cargo_tomls=($(find . -mindepth 2 -name Cargo.toml "${not_paths[@]}")) +# shellcheck disable=2207 +markdownFiles=($(find . -name "*.md" "${not_paths[@]}")) # Collect the name of all the internal crates crates=() @@ -105,6 +106,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