-
Notifications
You must be signed in to change notification settings - Fork 221
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
Showing
12 changed files
with
176 additions
and
38 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
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
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,18 @@ | ||
## `skip_lfs` | ||
|
||
**Default:** `false` | ||
|
||
Skip running LFS hooks even if it exists on your system. | ||
|
||
### Example | ||
|
||
```yml | ||
# lefthook.yml | ||
|
||
skip_lfs: true | ||
|
||
pre-push: | ||
commands: | ||
test: | ||
run: yarn test | ||
``` |
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
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,86 @@ | ||
## lefthook-local.yml | ||
|
||
`lefthook-local.yml` overrides and extends the configuration of your main `lefthook.yml` (or `lefthook.toml`, [etc.](../configuration)) file. | ||
|
||
> **Tip:** You can put `lefthook-local.yml` into your `~/.gitignore`, so in every project you can have your local-only overrides. | ||
*Special feature* of `lefthook-local.yml`: you can wrap the commands using `{cmd}` template. | ||
|
||
```yml | ||
# lefthook.yml | ||
|
||
pre-commit: | ||
commands: | ||
lint-frontend: | ||
run: yarn lint | ||
glob: ".{ts,tsx}" | ||
lint-backend: | ||
run: bundle exec rubocop {staged_files} | ||
glob: "*.rb" | ||
test-frontend: | ||
run: yarn test | ||
glob: "*.tsx" | ||
test-backend: | ||
run: bundle exec rspec | ||
glob: "spec/*" | ||
check-typos: | ||
run: typos {staged_files} | ||
check-links: | ||
run: lychee {staged_files} | ||
``` | ||
```yml | ||
# lefthook-local.yml | ||
|
||
pre-commit: | ||
parallel: true # run all commands concurrently | ||
commands: | ||
lint-backend: | ||
run: docker-compose run backend {cmd} # wrap the original command with docker-compose | ||
test-backend: | ||
run: docker-compose run backend {cmd} | ||
check-links: | ||
skip: true # skip checking links | ||
|
||
# Add another hook | ||
post-merge: | ||
files: "git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD" | ||
commands: | ||
dependencies: | ||
glob: "Gemfile*" | ||
run: docker-compose run backend bundle install | ||
``` | ||
--- | ||
```yml | ||
# The resulting config would look like this | ||
|
||
pre-commit: | ||
parallel: true | ||
commands: | ||
lint-frontend: | ||
run: yarn lint | ||
glob: "*.{ts,tsx}" | ||
lint-backend: | ||
run: docker-compose run backend bundle exec rubocop {staged_files} | ||
glob: "*.rb" | ||
test-frontend: | ||
run: yarn test | ||
glob: "*.tsx" | ||
test-backend: | ||
run: docker-compose run backend bundle exec rspec | ||
glob: "spec/*" | ||
check-links: | ||
run: lychee {staged_files} | ||
skip: true | ||
check-typos: | ||
run: typos {staged_files} | ||
|
||
post-merge: | ||
files: "git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD" | ||
commands: | ||
dependencies: | ||
glob: "Gemfile*" | ||
run: docker-compose run backend bundle install | ||
``` |
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
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,34 @@ | ||
## Skip or run on condition | ||
|
||
Here are two hooks. | ||
|
||
`pre-commit` hook will only be executed when you're committing something on a branch starting with `def/` prefix. | ||
|
||
In `pre-push` hook: | ||
- `test` command will be skipped if `NO_TEST` env variable is set to `1` | ||
- `lint` command will only be executed if you're pushing the `main` branch | ||
|
||
```yml | ||
# lefthook.yml | ||
|
||
pre-commit: | ||
only: | ||
- ref: dev/* | ||
commands: | ||
lint: | ||
run: yarn lint {staged_files} --fix | ||
glob: "*.{ts,js}" | ||
test: | ||
run: yarn test | ||
|
||
pre-push: | ||
commands: | ||
test: | ||
run: yarn test | ||
skip: | ||
- run: test "$NO_TEST" -eq 1 | ||
lint: | ||
run: yarn lint | ||
only: | ||
- ref: main | ||
``` |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
## Manuall installation with prebuilt executable | ||
|
||
Or take it from [binaries](https://github.com/evilmartians/lefthook/releases) and install manually. | ||
Download from [binaries](https://github.com/evilmartians/lefthook/releases) and install manually. | ||
|
||
1. Download the executable for your OS and Arch | ||
1. Put the executable under the $PATH (for unix systems) |
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
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
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