diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3fbdd9a2..8cb1fed6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,7 +20,7 @@ and relies on similar information. For example, if implementing a lint that uses information about attributes, find other lints that check attribute information and use them as guides as you write your lint. -Make sure to check the ["Development Environment"](#development-environment) section, especially if you are using Mac or Windows. +Make sure to check the ["Development Environment"](#development-environment) section, especially if you are using Windows. The ["Adding a new lint"](#adding-a-new-lint) section of this document has a walkthrough for defining and testing new lints. @@ -250,9 +250,7 @@ expected output files to include the new items, and you can get back on track. ## Development Environment While cargo-semver-checks is cross platform, the development task automation scripts in the scripts -directory are not. In particular, a relatively modern `bash` (at least version 4.0) is required. +directory require a `bash` shell to run. -Linux users likely have bash 5+ already installed or available via their package manager. Windows users can get a bash + GNU command line environment via WSL or git bash. -Mac users can install an updated bash via homebrew. The scripts will not work -correctly using the default version of bash that comes with Mac OS. +Linux and Mac OS typically have bash installed by default. diff --git a/scripts/regenerate_test_rustdocs.sh b/scripts/regenerate_test_rustdocs.sh index 55899389..20e2e0a8 100755 --- a/scripts/regenerate_test_rustdocs.sh +++ b/scripts/regenerate_test_rustdocs.sh @@ -6,15 +6,15 @@ if [ -z "$BASH_VERSION" ]; then exit 1 fi -# have bash, check version -if (( BASH_VERSINFO[0] < 4 )); then - >&2 printf 'This script requires bash version 4.0 or greater.\n' - exit 1 -fi - # Fail on first error, on undefined variables, and on failures in pipelines. set -euo pipefail +dir_is_newer_than_file() { + local dir="$1" + local file="$2" + [[ ! -e $file ]] || [[ $(find "$dir" -newer "$file" -exec sh -c 'printf found; kill "$PPID"' \;) ]] +} + export CARGO_TARGET_DIR=/tmp/test_crates RUSTDOC_OUTPUT_DIR="$CARGO_TARGET_DIR/doc" TOPLEVEL="$(git rev-parse --show-toplevel)" @@ -32,19 +32,6 @@ echo "Generating rustdoc with: $(cargo $TOOLCHAIN --version)" RUSTDOC_CMD="cargo $TOOLCHAIN rustdoc" # Run rustdoc on test_crates/*/{new,old}/ -shopt -s globstar -dir_is_newer_than_file() { - local dir=$1 - local file=$2 - local f - for f in "$dir"/**; do - if [[ $f -nt $file ]]; then - return 0 - fi - done - return 1 -} - if [[ $# -eq 0 ]]; then set -- "$TOPLEVEL/test_crates/"*/ always_update=