-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
44d7182
commit 70b4ca5
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Git Hooks | ||
|
||
A pre-push hook which checks formatting of Rust files. Additional checks may be added in the future. | ||
|
||
# Prerequisites | ||
|
||
The following prerequisites are required: | ||
|
||
## Rust Nightly | ||
|
||
The nightly version of Rust provides additional formatting benefits over the stable version. | ||
|
||
```shell | ||
rustup toolchain install nightly --profile minimal --component rustfmt | ||
``` | ||
|
||
# Installation | ||
|
||
Use the following command in the root directory of the local repository to configure Git to use the hooks: | ||
|
||
```shell | ||
git config core.hooksPath .githooks | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh | ||
|
||
set -eu | ||
|
||
# Check Rust formatting | ||
if ! cargo +nightly fmt --all -- --check | ||
then | ||
echo "There are some code style issues." | ||
# shellcheck disable=SC2006 | ||
echo "Run 'cargo +nightly fmt --all' first." | ||
exit 1 | ||
fi | ||
|
||
exit 0 |