Skip to content

Commit bb3fbb5

Browse files
committed
Add documentation for pre-commit hook
Signed-off-by: Priyanshi Gaur <noxdot1134@gmail.com>
1 parent 34cc9a5 commit bb3fbb5

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

.pre-commit-config.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ repos:
3636
- --fix=no
3737
- id: trailing-whitespace
3838

39-
repos:
4039
- repo: local
4140
hooks:
4241
- id: black
@@ -55,4 +54,4 @@ repos:
5554
name: "isort"
5655
entry: isort --filter-files
5756
language: system
58-
types: ["file", "python", "text"]
57+
types: ["file", "python", "text"]

README.md

+24-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,26 @@ follow these steps:
7676
7777
### Static analysis
7878
79+
#### Using [`pre-commit`][pre-commit]
80+
1. Install pre-commit
81+
82+
- Using pip:
83+
```shell
84+
pip install pre-commit
85+
```
86+
- Using homebrew:
87+
```shell
88+
brew install pre-commit
89+
```
90+
91+
2. Install the git hook scripts
92+
```shell
93+
pre-commit install
94+
```
95+
96+
It will run on every commit automatically.
97+
98+
#### Using [`dev/tools.sh`][tools-sh] helper script
7999
The [`dev/tools.sh`][tools-sh] helper script runs the static analysis tools
80100
(`black`, `flake8`, and `isort`):
81101
```shell
@@ -89,6 +109,7 @@ directories to check:
89109
```
90110
91111
[tools-sh]: /dev/tools.sh
112+
[pre-commit]: https://pre-commit.com/
92113
93114
94115
### Resources
@@ -100,12 +121,14 @@ directories to check:
100121
- [isort][isort]: _A Python utility / library to sort imports_
101122
- (It doesn't import any libraries, it only sorts and formats them.)
102123
- [ppypa/pipenv][pipenv]: _Python Development Workflow for Humans._
124+
- [pre-commit][pre-commit]: A framework for managing and maintaining multi-language pre-commit hooks.
103125

104126
[ccospyguide]: https://opensource.creativecommons.org/contributing-code/python-guidelines/
105127
[black]: https://github.com/psf/black
106128
[flake8]: https://gitlab.com/pycqa/flake8
107129
[isort]: https://pycqa.github.io/isort/
108130
[pipenv]: https://github.com/pypa/pipenv
131+
[pre-commit]: https://pre-commit.com/
109132

110133

111134
### GitHub Actions
@@ -115,7 +138,7 @@ GitHub Actions workflow performs static analysis (`black`, `flake8`, and
115138
`isort`) on committed changes. The workflow is triggered automatically when you
116139
push changes to the main branch or open a pull request.
117140

118-
[workflow-static-analysis]: .github/workflows/python_static_analysis.yml
141+
[workflow-static-analysis]: .github/workflows/static_analysis.yml
119142

120143

121144
## Data sources

0 commit comments

Comments
 (0)