-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add lefthook option for custom path or command (#927)
- Loading branch information
Showing
10 changed files
with
113 additions
and
4 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,62 @@ | ||
## `lefthook` | ||
|
||
**Default:** `null` | ||
|
||
Provide a full path to lefthook executable or a command to run lefthook. Bourne shell (`sh`) syntax is supported. | ||
|
||
> **Important:** This option does not merge from `remotes` or `extends` for security reasons. But it gets merged from lefthook local config if specified. | ||
There are three reasons you may want to specify `lefthook`: | ||
|
||
1. You want to force using specific lefthook version from your dependencies (e.g. npm package) | ||
1. You use OnP loader for your JS/TS project, and your `package.json` with lefthook dependency locates in a subfolder | ||
1. You want to make sure you use concrete lefthook executable path and want to defined it in `lefthook-local.yml` | ||
|
||
### Examples | ||
|
||
#### Specify lefthook executable | ||
|
||
```yml | ||
# lefthook.yml | ||
|
||
lefthook: /usr/bin/lefthook | ||
|
||
pre-commit: | ||
jobs: | ||
- run: yarn lint | ||
``` | ||
#### Specify a command to run lefthook | ||
```yml | ||
# lefthook.yml | ||
|
||
lefthook: | | ||
cd project-with-lefthook | ||
pnpm lefthook | ||
pre-commit: | ||
jobs: | ||
- run: yarn lint | ||
root: project-with-lefthook | ||
``` | ||
#### Force using a version from Rubygems | ||
```yml | ||
# lefthook.yml | ||
|
||
lefthook: bundle exec lefthook | ||
|
||
pre-commit: | ||
jobs: | ||
- run: bundle exec rubocop {staged_files} | ||
``` | ||
#### Enable debug logs | ||
```yml | ||
# lefthook-local.yml | ||
|
||
lefthook: lefthook --verbose | ||
``` |
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
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
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,26 @@ | ||
exec git init | ||
exec lefthook install | ||
exec git config user.email "[email protected]" | ||
exec git config user.name "Your Name" | ||
exec git add -A | ||
exec git commit -m 'must show debug logs' | ||
stderr 'injected' | ||
stdout '[lefthook]' | ||
|
||
-- lefthook.yml -- | ||
lefthook: | | ||
echo 'injected' | ||
lefthook -v | ||
|
||
output: | ||
- execution | ||
pre-commit: | ||
jobs: | ||
- run: echo {all_files} | ||
glob: "*.txt" | ||
|
||
-- file.txt -- | ||
sometext | ||
|
||
-- file.js -- | ||
somecode |