Merge pull request #3041 from G8XSU/followup-2957
[rust-lightning] / ci / rustfmt.sh
1 #!/bin/bash
2 set -eox pipefail
3
4 # Generate initial exclusion list
5 #find . -name '*.rs' -type f |sort >rustfmt_excluded_files
6
7 # The +rustversion syntax only works with rustup-installed rust toolchains,
8 # not with any distro-provided ones. Thus, we check for a rustup install and
9 # only pass +1.63.0 if we find one.
10 VERS=""
11 [ "$(which rustup)" != "" ] && VERS="+1.63.0"
12
13 # Run fmt
14 TMP_FILE=$(mktemp)
15 find . -name '*.rs' -type f |sort >$TMP_FILE
16 for file in $(comm -23 $TMP_FILE rustfmt_excluded_files); do
17         echo "Checking formatting of $file"
18         rustfmt $VERS --check $file
19 done