Skip to content

Commit b6b621f

Browse files
Comply with TOML string requirements
Drops string handling from pre-commit entirely. rustfmt --config option can't be used with the parameters 'as is' (string values as unquoted). Instead use rustfmt --config-path that takes the whole fmt.toml file. To be able to use --config-path requires the nightly toolchain to be added to the docker dev container as well. This change additionally drops the license-template-path formatting parameter as it is no longer supported by the rust toolchain. See github discussion: rust-lang/rustfmt#3352 Signed-off-by: Matthew Schlebusch <[email protected]>
1 parent d95f736 commit b6b621f

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

pre-commit

+4-5
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@ for i in $(git diff --name-only --cached); do
2222
filename=$(basename -- "$i")
2323
extension="${filename##*.}"
2424
if [ "$extension" = "rs" ]; then
25-
# Read rustfmt config, replace '\n' with ','
26-
rustfmt_config="$(sed -z "s/\n/,/g;s/,$/\n/" ./tests/fmt.toml)"
2725
# We first do a check run, this will fail when it finds a non-matching license.
28-
rustfmt $i --check --config $rustfmt_config
29-
# Run `cargo fmt` for this file
30-
rustfmt $i --config $rustfmt_config
26+
rustfmt $i +nightly --check --config-path ./tests/fmt.toml
27+
28+
# Run `cargo fmt` for this source file using the fmt.toml config
29+
rustfmt $i +nightly --config-path ./tests/fmt.toml
3130
fi
3231
if [ "$extension" = "py" ]; then
3332
# Run `black` for this file

tests/fmt.toml

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
# This file can be used as a whole TOML file via rustfmt's --config-path option
2+
# The individual key-pairs can also used with the rustfmt --config option,
3+
# but requires removing the quotes to work
4+
15
comment_width=100
26
wrap_comments=true
37
format_code_in_doc_comments=true
48
format_strings=true
5-
license_template_path=./tests/license.txt
6-
imports_granularity=Module
9+
imports_granularity="Module"
710
normalize_comments=true
811
normalize_doc_attributes=true
9-
group_imports=StdExternalCrate
12+
group_imports="StdExternalCrate"

tools/devctr/Dockerfile.aarch64

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ RUN cd "$TMP_POETRY_DIR" \
9999
RUN mkdir "$TMP_BUILD_DIR" \
100100
&& curl https://sh.rustup.rs -sSf | sh -s -- -y --profile minimal --default-toolchain "$RUST_TOOLCHAIN" \
101101
&& rustup target add aarch64-unknown-linux-musl \
102+
&& rustup install nightly
103+
&& rustup default stable \
102104
&& rustup component add clippy \
103105
&& cd "$TMP_BUILD_DIR" \
104106
&& cargo install cargo-kcov \

tools/devctr/Dockerfile.x86_64

+2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ RUN mkdir "$TMP_BUILD_DIR" \
109109
&& rustup target add x86_64-unknown-linux-musl \
110110
&& rustup component add rustfmt clippy clippy-preview \
111111
&& rustup install --profile minimal "stable" \
112+
&& rustup install nightly
113+
&& rustup default stable \
112114
&& cd "$TMP_BUILD_DIR" \
113115
&& cargo install cargo-kcov \
114116
&& cargo +"stable" install cargo-audit \

tools/devtool

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
DEVCTR_IMAGE_NO_TAG="public.ecr.aws/firecracker/fcuvm"
7373

7474
# Development container tag
75-
DEVCTR_IMAGE_TAG="v41"
75+
DEVCTR_IMAGE_TAG="v44"
7676

7777
# Development container image (name:tag)
7878
# This should be updated whenever we upgrade the development container.

0 commit comments

Comments
 (0)