Files
dbx/.husky/pre-commit
T
t8y2 e2959420fc fix: use cargo fmt instead of bare rustfmt in pre-commit hook
裸 rustfmt 不会读取 rustfmt.toml 配置,改用 cargo fmt --manifest-path
确保提交时格式化行为与手动 cargo fmt 一致。
2026-05-29 00:43:17 +08:00

21 lines
610 B
Plaintext
Executable File

npx lint-staged
# Only format and re-add Rust files that are already staged
TOPLEVEL=$(git rev-parse --show-toplevel)
format_staged_rust() {
local dir="$1"
local staged=""
staged=$(git diff --staged --name-only --diff-filter=ACM -- ":(top,literal)$dir/*.rs" ":(top,literal)$dir/**/*.rs" 2>/dev/null)
if [ -n "$staged" ]; then
cargo fmt --manifest-path "$TOPLEVEL/$dir/Cargo.toml"
echo "$staged" | while IFS= read -r f; do
git add "$TOPLEVEL/$f" 2>/dev/null || true
done
fi
}
format_staged_rust "src-tauri"
format_staged_rust "crates/dbx-core"
format_staged_rust "crates/dbx-web"