https://github.com/jetbridge/pre-commit-hooks
https://github.com/jetbridge/pre-commit-hooks
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jetbridge/pre-commit-hooks
- Owner: jetbridge
- Created: 2019-05-31T12:36:52.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-01T19:49:47.000Z (about 7 years ago)
- Last Synced: 2025-03-09T19:44:33.088Z (over 1 year ago)
- Language: Shell
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Pre-Commit Hooks
Collection of pre-commit hooks that can make your life easier :)
## Installation
### 1. If you don't have `pre-commit` installed in your project:
```
brew install pre-commit # make sure pre-commit is installed in your system
cd ~/
pre-commit install
touch .pre-commit-config.yaml
```
### 2. Edit your `.pre-commit-config.yaml` to add hooks from this project:
- Add (see the list of available hooks below):
```
- repo: git@github.com:jetbridge/pre-commit-hooks.git
rev: master
hooks:
- id: black
- id: flake8
- id: pytest
```
- Save `.pre-commit-config.yaml`
- Stage it:
```
git add .pre-commit-config.yaml
```
## Usage
Use `git commit` command to run the hooks and commit staged files.
Use `pre-commit run` to run the hooks without commiting.
Use `pre-commit autoupdate` to update the repo `rev` if you experience any problems running the hooks.
## List of hooks
### Black
Formats your staged files with Black formatter ([black](https://github.com/python/black) should be installed and configured in your project).
If some files have to be fixed, it will fix them and apply `git add` on them so your commit will not be rejected.
### Flake8
Runs flake8 linter to find any problems with file formatting according to specified rules ([flake8](http://flake8.pycqa.org/en/latest/) should be installed and configured in your project).
### Pytest
Runs pytest with flags `-xq`. It means that tests will be run in quiet mode and stopped on the first error or failure.
## Notes
- Please note that all unstaged files will be stashed once you ran the hooks.
- Be careful using different linters / formetters at the same time (like `black` and `flake8`). They may have different conflicts so in order to use them together you should solve them first.
## Additional info
Find more about pre-commit hooks [here](https://pre-commit.com/).
## Happy coding!