You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
while IFS=$'\n'read -r;do markdown_files+=("${REPLY}");done<<(ls_files '*.md')
237
+
if [[ ${TIDY_EXPECTED_MARKDOWN_FILE_COUNT:-${#markdown_files[@]}}-ne${#markdown_files[@]} ]];then
238
+
error "expected ${TIDY_EXPECTED_MARKDOWN_FILE_COUNT} of Markdown files, but found ${#markdown_files[@]}; consider updating TIDY_EXPECTED_MARKDOWN_FILE_COUNT env var"
239
+
fi
240
+
230
241
# Rust (if exists)
231
-
if [[ -n"$(ls_files '*.rs')" ]];then
242
+
rust_files=()
243
+
while IFS=$'\n'read -r;do rust_files+=("${REPLY}");done<<(ls_files '*.rs')
244
+
if [[ ${TIDY_EXPECTED_RUST_FILE_COUNT:-${#rust_files[@]}}-ne${#rust_files[@]} ]];then
245
+
error "expected ${TIDY_EXPECTED_RUST_FILE_COUNT} of Rust files, but found ${#rust_files[@]}; consider updating TIDY_EXPECTED_RUST_FILE_COUNT env var"
246
+
fi
247
+
if [[ ${#rust_files[@]}-gt 0 ]];then
232
248
info "checking Rust code style"
233
249
check_config .rustfmt.toml "; consider adding with reference to https://github.com/taiki-e/cargo-hack/blob/HEAD/.rustfmt.toml"
234
250
check_config .clippy.toml "; consider adding with reference to https://github.com/taiki-e/cargo-hack/blob/HEAD/.clippy.toml"
235
-
if check_install cargo jq python3 pipx;then
251
+
if check_install cargo jq pipx;then
236
252
# `cargo fmt` cannot recognize files not included in the current workspace and modules
237
253
# defined inside macros, so run rustfmt directly.
238
254
# We need to use nightly rustfmt because we use the unstable formatting options of rustfmt.
@@ -242,16 +258,16 @@ if [[ -n "$(ls_files '*.rs')" ]]; then
242
258
retry rustup component add rustfmt &>/dev/null
243
259
fi
244
260
info "running \`rustfmt \$(git ls-files '*.rs')\`"
if [[ -n"$(ls_files "${clang_format_ext[@]}")" ]];then
484
+
clang_format_files=()
485
+
while IFS=$'\n'read -r;do clang_format_files+=("${REPLY}");done<<(ls_files "${clang_format_ext[@]}")
486
+
if [[ ${TIDY_EXPECTED_CLANG_FORMAT_FILE_COUNT:-${#clang_format_files[@]}}-ne${#clang_format_files[@]} ]];then
487
+
error "expected ${TIDY_EXPECTED_CLANG_FORMAT_FILE_COUNT} of C/C++/Protobuf files, but found ${#clang_format_files[@]}; consider updating TIDY_EXPECTED_CLANG_FORMAT_FILE_COUNT env var"
488
+
fi
489
+
if [[ ${#clang_format_files[@]}-gt 0 ]];then
463
490
info "checking C/C++/Protobuf code style"
464
491
check_config .clang-format
465
492
if check_install clang-format;then
466
493
IFS=''
467
494
info "running \`clang-format -i \$(git ls-files ${clang_format_ext[*]})\`"
if [[ -n"$(ls_files "${prettier_ext[@]}")" ]];then
510
+
prettier_files=()
511
+
while IFS=$'\n'read -r;do prettier_files+=("${REPLY}");done<<(ls_files "${prettier_ext[@]}")
512
+
if [[ ${TIDY_EXPECTED_PRETTIER_FILE_COUNT:-${#prettier_files[@]}}-ne${#prettier_files[@]} ]];then
513
+
error "expected ${TIDY_EXPECTED_PRETTIER_FILE_COUNT} of YAML/HTML/CSS/JavaScript/JSON files, but found ${#prettier_files[@]}; consider updating TIDY_EXPECTED_PRETTIER_FILE_COUNT env var"
514
+
fi
515
+
if [[ ${#prettier_files[@]}-gt 0 ]];then
484
516
info "checking YAML/HTML/CSS/JavaScript/JSON code style"
485
517
check_config .editorconfig
486
518
if check_install npm;then
487
519
IFS=''
488
520
info "running \`npx -y prettier -l -w \$(git ls-files ${prettier_ext[*]})\`"
error "check failed; please resolve the above markdownlint error(s)"
524
561
fi
525
562
fi
@@ -580,6 +617,12 @@ if [[ -n "$(ls_files '*action.yml')" ]]; then
580
617
fi
581
618
done
582
619
fi
620
+
if [[ ${TIDY_EXPECTED_SHELL_FILE_COUNT:-${#shell_files[@]}}-ne${#shell_files[@]} ]];then
621
+
error "expected ${TIDY_EXPECTED_SHELL_FILE_COUNT} of shell script files, but found ${#shell_files[@]}; consider updating TIDY_EXPECTED_SHELL_FILE_COUNT env var"
622
+
fi
623
+
if [[ ${TIDY_EXPECTED_DOCKER_FILE_COUNT:-${#docker_files[@]}}-ne${#docker_files[@]} ]];then
624
+
error "expected ${TIDY_EXPECTED_DOCKER_FILE_COUNT} of dockerfiles, but found ${#docker_files[@]}; consider updating TIDY_EXPECTED_DOCKER_FILE_COUNT env var"
0 commit comments