2024-02-05 15:44:08 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -eox pipefail
|
|
|
|
|
2024-08-06 15:13:59 +00:00
|
|
|
export LC_ALL=C
|
|
|
|
|
2024-02-05 15:44:08 +01:00
|
|
|
# Generate initial exclusion list
|
|
|
|
#find . -name '*.rs' -type f |sort >rustfmt_excluded_files
|
|
|
|
|
2024-04-22 13:03:14 +00:00
|
|
|
# The +rustversion syntax only works with rustup-installed rust toolchains,
|
|
|
|
# not with any distro-provided ones. Thus, we check for a rustup install and
|
|
|
|
# only pass +1.63.0 if we find one.
|
|
|
|
VERS=""
|
|
|
|
[ "$(which rustup)" != "" ] && VERS="+1.63.0"
|
|
|
|
|
2024-02-05 15:44:08 +01:00
|
|
|
# Run fmt
|
|
|
|
TMP_FILE=$(mktemp)
|
2024-09-18 18:03:11 +00:00
|
|
|
git ls-files | grep '.rs$' | sort >"$TMP_FILE"
|
2024-04-25 15:32:32 +02:00
|
|
|
for file in $(comm -23 "$TMP_FILE" rustfmt_excluded_files); do
|
2024-02-05 15:44:08 +01:00
|
|
|
echo "Checking formatting of $file"
|
2024-04-25 15:32:32 +02:00
|
|
|
rustfmt $VERS --edition 2021 --check "$file"
|
2024-02-05 15:44:08 +01:00
|
|
|
done
|