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.
This commit is contained in:
Tobin C. Harding 2024-03-28 09:08:08 +11:00
parent 133531fab7
commit 35687c84fc
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 4 additions and 8 deletions

View File

@ -7,14 +7,10 @@ set -euo pipefail
config=.github/labeler.yml config=.github/labeler.yml
if [ -n "$SCAN_DIR" ]; # Define a default value for SCAN_DIR if not set
then : "${SCAN_DIR:=.}"
scan_dir="$SCAN_DIR"
else
scan_dir=.
fi
if [ "$1" '!=' "--force" ] && ! git diff --exit-code "$config"; if [ "${1:-default}" '!=' "--force" ] && ! git diff --exit-code "$config";
then then
echo "Error: $config is not committed." echo "Error: $config is not committed."
echo "Refusing to overwrite it to prevent disaster." echo "Refusing to overwrite it to prevent disaster."
@ -24,7 +20,7 @@ fi
excluded_crates="fuzz|dep_test" 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; for crate in $CRATES;
do do