rust/util/etc/pre-commit.sh
Ada Alakbarova 2304a9cb76
remove non-existent pathspec from pre-commit hook
it was added back in 6035e050e83cc991f94797eef4d720c0b61d8955, at which
time there were some files matching it, e.g.
6035e050e8/clippy_lints/src/lib.deprecated.rs
2025-04-23 00:47:43 +02:00

22 lines
660 B
Bash
Executable File

#!/bin/sh
# hide output
set -e
# Update lints
cargo dev update_lints
git add clippy_lints/src/lib.rs
# Formatting:
# Git will not automatically add the formatted code to the staged changes once
# fmt was executed. This collects all staged files rs files that are currently staged.
# They will later be added back.
#
# This was proudly stolen and adjusted from here:
# https://medium.com/@harshitbangar/automatic-code-formatting-with-git-66c3c5c26798
files=$( (git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.rs$") || true)
if [ ! -z "${files}" ]; then
cargo dev fmt
git add $(echo "$files" | paste -s -d " " -)
fi