From 35687c84fc5b71435307b74190a0a2ad0abf162f Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Thu, 28 Mar 2024 09:08:08 +1100 Subject: [PATCH] CI: Fix Manage PR job In #2635 we broke the Manage PR CI job but for some reason CI didn't run on that PR so we merged the breakage. Fix the script by setting default variables when they are not set. Done with ChatGPT. --- contrib/gen_label_config.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/contrib/gen_label_config.sh b/contrib/gen_label_config.sh index 9ad7e626..089bd30d 100755 --- a/contrib/gen_label_config.sh +++ b/contrib/gen_label_config.sh @@ -7,14 +7,10 @@ set -euo pipefail config=.github/labeler.yml -if [ -n "$SCAN_DIR" ]; -then - scan_dir="$SCAN_DIR" -else - scan_dir=. -fi +# Define a default value for SCAN_DIR if not set +: "${SCAN_DIR:=.}" -if [ "$1" '!=' "--force" ] && ! git diff --exit-code "$config"; +if [ "${1:-default}" '!=' "--force" ] && ! git diff --exit-code "$config"; then echo "Error: $config is not committed." echo "Refusing to overwrite it to prevent disaster." @@ -24,7 +20,7 @@ fi excluded_crates="fuzz|dep_test" -CRATES="`cd "$scan_dir" && cargo metadata --no-deps --format-version 1 | jq -j -r '.packages | map(.manifest_path | rtrimstr("/Cargo.toml") | ltrimstr("'$PWD'/")) | join(" ")'`" +CRATES="`cd "$SCAN_DIR" && cargo metadata --no-deps --format-version 1 | jq -j -r '.packages | map(.manifest_path | rtrimstr("/Cargo.toml") | ltrimstr("'$PWD'/")) | join(" ")'`" for crate in $CRATES; do