cargo-lock-updater initial commit

This commit is contained in:
Alex Janka 2024-08-23 09:40:05 +10:00
commit ae31892358
2 changed files with 18 additions and 0 deletions

6
.pre-commit-hooks.yaml Normal file
View file

@ -0,0 +1,6 @@
- id: cargo-lock
name: Fix Cargo.lock
description: Updates Cargo.lock
entry: cargo-lock-updater
language: script
types: [text]

12
cargo-lock-updater Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env zsh
find . -type f -name 'Cargo.lock' -print0 | while IFS=$'\0' read -r -d '' file; do
(cd "$(dirname "$file")" && cargo update -wq)
git add $file
done
if [ -f "Makefile" ]; then
if [ ! -z $(grep "fmt-check:" "Makefile") ]; then
make fmt-check 2>&1 >/dev/null
fi
fi