Skip to content

Commit

Permalink
chore: add pre-push hook
Browse files Browse the repository at this point in the history
  • Loading branch information
evilrobot-01 committed Aug 14, 2024
1 parent 44d7182 commit 70b4ca5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .githooks/README.md
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
```

14 changes: 14 additions & 0 deletions .githooks/pre-push
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

0 comments on commit 70b4ca5

Please sign in to comment.