From 167f0002e4a37d249d5a4e583dcf102ce327344c Mon Sep 17 00:00:00 2001
From: librelois <c@elo.tf>
Date: Wed, 26 Jan 2022 21:04:08 +0100
Subject: [PATCH] git: add a pre-commit hook that run rustfmt --check

---
 .rusty-hook.toml |  5 +++++
 Cargo.lock       | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
 Cargo.toml       |  3 +++
 3 files changed, 61 insertions(+)
 create mode 100644 .rusty-hook.toml

diff --git a/.rusty-hook.toml b/.rusty-hook.toml
new file mode 100644
index 000000000..36953ed9a
--- /dev/null
+++ b/.rusty-hook.toml
@@ -0,0 +1,5 @@
+[hooks]
+pre-commit = "cargo fmt -- --check"
+
+[logging]
+verbose = true
diff --git a/Cargo.lock b/Cargo.lock
index 9dab97d18..c7d6a348f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -753,6 +753,15 @@ dependencies = [
  "winapi 0.3.9",
 ]
 
+[[package]]
+name = "ci_info"
+version = "0.10.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24f638c70e8c5753795cc9a8c07c44da91554a09e4cf11a7326e8161b0a3c45e"
+dependencies = [
+ "envmnt",
+]
+
 [[package]]
 name = "cid"
 version = "0.6.1"
@@ -1244,6 +1253,7 @@ dependencies = [
  "pallet-grandpa",
  "pallet-transaction-payment-rpc",
  "pallet-transaction-payment-rpc-runtime-api",
+ "rusty-hook",
  "sc-basic-authorship",
  "sc-chain-spec",
  "sc-cli",
@@ -1395,6 +1405,16 @@ version = "1.1.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "68b91989ae21441195d7d9b9993a2f9295c7e1a8c96255d8b729accddc124797"
 
+[[package]]
+name = "envmnt"
+version = "0.8.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2d328fc287c61314c4a61af7cfdcbd7e678e39778488c7cb13ec133ce0f4059"
+dependencies = [
+ "fsio",
+ "indexmap",
+]
+
 [[package]]
 name = "event-listener"
 version = "2.5.1"
@@ -1706,6 +1726,12 @@ dependencies = [
  "winapi 0.3.9",
 ]
 
+[[package]]
+name = "fsio"
+version = "0.1.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c1fd087255f739f4f1aeea69f11b72f8080e9c2e7645cd06955dad4a178a49e3"
+
 [[package]]
 name = "fuchsia-zircon"
 version = "0.3.3"
@@ -1992,6 +2018,15 @@ dependencies = [
  "version_check",
 ]
 
+[[package]]
+name = "getopts"
+version = "0.2.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
+dependencies = [
+ "unicode-width",
+]
+
 [[package]]
 name = "getrandom"
 version = "0.1.16"
@@ -3934,6 +3969,12 @@ dependencies = [
  "winapi 0.3.9",
 ]
 
+[[package]]
+name = "nias"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ab250442c86f1850815b5d268639dff018c0627022bc1940eb2d642ca1ce12f0"
+
 [[package]]
 name = "nodrop"
 version = "0.1.14"
@@ -5474,6 +5515,18 @@ dependencies = [
  "base64",
 ]
 
+[[package]]
+name = "rusty-hook"
+version = "0.11.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "96cee9be61be7e1cbadd851e58ed7449c29c620f00b23df937cb9cbc04ac21a3"
+dependencies = [
+ "ci_info",
+ "getopts",
+ "nias",
+ "toml",
+]
+
 [[package]]
 name = "rw-stream-sink"
 version = "0.2.1"
diff --git a/Cargo.toml b/Cargo.toml
index 21c3818fa..cc47fe186 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -34,6 +34,9 @@ runtime-benchmarks = [
 [build-dependencies]
 substrate-build-script-utils = { git = 'https://github.com/librelois/substrate.git', branch = 'duniter-monthly-2022-01' }
 
+[dev-dependencies]
+rusty-hook = "^0.11.2"
+
 [dependencies]
 
 # local dependencies
-- 
GitLab