From 4596ec6a7d332b4de19cf9c91963af5d96f2f306 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Sat, 23 Dec 2023 03:04:19 +0000 Subject: [PATCH] githooks: add pre-commit hook with dry `cargo fmt` --- .githooks/pre-commit | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 0000000..27236a0 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,11 @@ +#!/bin/bash + +diff=$(cargo fmt -- --check) +result=$? + +if [ ${result} -ne 0 ]; then + echo "There are some code formatting issues, run `cargo fmt` first." + exit 1 +fi + +exit 0