commit ae31892358b0e4d0f1891e44fb298f929f8cdebc Author: Alex Janka Date: Fri Aug 23 09:40:05 2024 +1000 cargo-lock-updater initial commit diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..bffed73 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,6 @@ +- id: cargo-lock + name: Fix Cargo.lock + description: Updates Cargo.lock + entry: cargo-lock-updater + language: script + types: [text] diff --git a/cargo-lock-updater b/cargo-lock-updater new file mode 100755 index 0000000..44963b1 --- /dev/null +++ b/cargo-lock-updater @@ -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