We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0a5f28c commit 41bc0f4Copy full SHA for 41bc0f4
util/etc/pre-commit.sh
@@ -1,3 +1,21 @@
1
#!/bin/sh
2
3
-cargo dev fmt
+# hide output
4
+set -e
5
+
6
+# Update lints
7
+cargo dev update_lints
8
+git add clippy_lints/src/lib.rs
9
10
+# Formatting:
11
+# Git will not automatically add the formatted code to the staged changes once
12
+# fmt was executed. This collects all staged files rs files that are currently staged.
13
+# They will later be added back.
14
+#
15
+# This was proudly stolen and adjusted from here:
16
+# https://medium.com/@harshitbangar/automatic-code-formatting-with-git-66c3c5c26798
17
+files=$( (git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.rs$") || true)
18
+if [ ! -z "${files}" ]; then
19
+ cargo dev fmt
20
+ git add $(echo "$files" | paste -s -d " " -)
21
+fi
0 commit comments