]> git.lizzy.rs Git - rust.git/blob - util/etc/pre-commit.sh
Auto merge of #9989 - xFrednet:9986-move-safety-thingy, r=flip1995
[rust.git] / util / etc / pre-commit.sh
1 #!/bin/sh
2
3 # hide output
4 set -e
5
6 # Update lints
7 cargo dev update_lints
8 git add clippy_lints/src/lib.rs
9 git add clippy_lints/src/lib.*.rs
10
11 # Formatting:
12 #     Git will not automatically add the formatted code to the staged changes once
13 #     fmt was executed. This collects all staged files rs files that are currently staged.
14 #     They will later be added back.
15 #
16 #     This was proudly stolen and adjusted from here:
17 #     https://medium.com/@harshitbangar/automatic-code-formatting-with-git-66c3c5c26798
18 files=$( (git diff --cached --name-only --diff-filter=ACMR | grep -Ei "\.rs$") || true)
19 if [ ! -z "${files}" ]; then
20     cargo dev fmt
21     git add $(echo "$files" | paste -s -d " " -)
22 fi