From a0abc631685a083fa7a35a1571d640c7943e3203 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ho=C3=A0ng=20=C4=90=E1=BB=A9c=20Hi=E1=BA=BFu?= Date: Sun, 24 Feb 2019 10:19:37 +0700 Subject: [PATCH] add fmt-checking hook --- README.md | 7 ++++++- scripts/pre-commit | 4 ++++ src/bluetooth.rs | 10 +++++++--- src/led.rs | 8 ++++++-- 4 files changed, 23 insertions(+), 6 deletions(-) create mode 100755 scripts/pre-commit diff --git a/README.md b/README.md index 81984cd..e02e59d 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,12 @@ To analyze the firmware's code size, you need [cargo-bloat](https://github.com/R - `make bloat` - `make bloat BLOAT_ARGS="--crates" # passing arguments to cargo-bloat` -Our CI requires consistent formatting, please run rustfmt before you submit PRs: +Our CI requires consistent formatting, please use our pre-commit hook +to make sure: + +- `cp scripts/pre-commit .git/hooks/pre-commit` + +To fix formatting: - `make fmt` diff --git a/scripts/pre-commit b/scripts/pre-commit new file mode 100755 index 0000000..834b68a --- /dev/null +++ b/scripts/pre-commit @@ -0,0 +1,4 @@ +#!/bin/sh +set -e + +cargo fmt --all -- --check diff --git a/src/bluetooth.rs b/src/bluetooth.rs index 8fb9fbe..5aa0a4f 100644 --- a/src/bluetooth.rs +++ b/src/bluetooth.rs @@ -153,7 +153,8 @@ where .log_error(); } _ => { - crate::heprintln!("msg: System {} {:?}", message.operation, message.data).ok(); + crate::heprintln!("msg: System {} {:?}", message.operation, message.data) + .ok(); } } } @@ -230,7 +231,8 @@ where crate::heprintln!("TODO: Keyboard Sync").ok(); } _ => { - crate::heprintln!("msg: Keyboard {} {:?}", message.operation, message.data).ok(); + crate::heprintln!("msg: Keyboard {} {:?}", message.operation, message.data) + .ok(); } }, MsgType::Macro => match MacroOp::from(message.operation) { @@ -244,7 +246,9 @@ where _ => { crate::heprintln!( "msg: {:?} {} {:?}", - message.msg_type, message.operation, message.data + message.msg_type, + message.operation, + message.data ) .ok(); } diff --git a/src/led.rs b/src/led.rs index f2016d7..1bcf0b5 100644 --- a/src/led.rs +++ b/src/led.rs @@ -222,7 +222,9 @@ where _ => { crate::heprintln!( "lmsg: {:?} {} {:?}", - message.msg_type, message.operation, message.data + message.msg_type, + message.operation, + message.data ) .ok(); } @@ -231,7 +233,9 @@ where _ => { crate::heprintln!( "lmsg: {:?} {} {:?}", - message.msg_type, message.operation, message.data + message.msg_type, + message.operation, + message.data ) .ok(); }