Skip to content

Commit

Permalink
Add a managed hooks folder and installation instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs committed Oct 21, 2023
1 parent 8230e9d commit d421791
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
14 changes: 11 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,18 @@ To check everything in one go, run `./scripts/check.sh`. `check.sh` should ideal
Prior to pushing changes to a PR, at a minimum, you should always run `just fast-lint`. This is designed to run
in a few seconds and should catch the more trivial issues to avoid wasting CI time.

We strongly recommend adding fast-lint to a pre-push hook. For example, copy the following to: `.git/hooks/pre-push`:
### Hooks
We recommend adding the rerun pre-push hook to your local checkout, which among other-things will run
`just fast-lint` for you.

To install the hooks, simply copy them into the `.git/hooks` directory of your local checkout.
```
cp hooks/pre-push .git/hooks/pre-push
chmod +x .git/hooks/pre-push
```
or if you prefer you can configure git to use this directory as the hooks directory:
```
#!/bin/sh
just fast-lint
git config core.hooksPath hooks
```

### Optional
Expand Down
16 changes: 16 additions & 0 deletions hooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Hooks
This folder contains the official rerun githooks.

Each hook is designed to call through to a corresponding hook in the scripts directory.
- `pre-push` -> `scripts/pre-push.sh`

### Installation
To install the hooks, simply copy them into the `.git/hooks` directory of your local checkout.
```
cp hooks/pre-push .git/hooks/pre-push
chmod +x .git/hooks/pre-push
```
or if you prefer you can configure git to use this directory as the hooks directory:
```
git config core.hooksPath hooks
```
6 changes: 6 additions & 0 deletions hooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# This is a shim to call through to the managed pre-push hook.
# See: hooks/README.md for more details.
repo_root=$(git rev-parse --show-toplevel)
sh $repo_root/scripts/pre-push.sh
6 changes: 6 additions & 0 deletions scripts/pre-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

# This script is intended to be called from the git pre-push hook.
# See: hooks/README.md for more details.

just fast-lint

0 comments on commit d421791

Please sign in to comment.