From 6da03d0c49ea3bd95bef4fb877e7774eef1e1b29 Mon Sep 17 00:00:00 2001 From: Predrag Gruevski Date: Thu, 15 Aug 2024 02:05:29 +0000 Subject: [PATCH] Allow generating test rustdoc JSON files without git dependency. --- scripts/regenerate_test_rustdocs.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/regenerate_test_rustdocs.sh b/scripts/regenerate_test_rustdocs.sh index 20e2e0a8..5fd3534f 100755 --- a/scripts/regenerate_test_rustdocs.sh +++ b/scripts/regenerate_test_rustdocs.sh @@ -17,7 +17,13 @@ dir_is_newer_than_file() { export CARGO_TARGET_DIR=/tmp/test_crates RUSTDOC_OUTPUT_DIR="$CARGO_TARGET_DIR/doc" -TOPLEVEL="$(git rev-parse --show-toplevel)" + +# Get the top-level directory of the project (the repo): +# - If the user has cloned the git repo, ask git. +# - Otherwise, navigate up relative to this script's path. +# This latter option is useful when building cargo-semver-checks for distribution with NixOS: +# https://github.com/obi1kenobi/cargo-semver-checks/issues/855 +TOPLEVEL="$(git rev-parse --show-toplevel 2>/dev/null || cd -- "$(dirname -- "${BASH_SOURCE[0]}" )" &>/dev/null && cd -- .. &>/dev/null && pwd)" TARGET_DIR="$TOPLEVEL/localdata/test_data" TOOLCHAIN=