Skip to content

Commit 8c95d16

Browse files
nineteendoezio-melottierlend-aaslandhugovk
authored
Add pre-commit setup to the Setup and Building chapter (#1306)
Co-authored-by: Ezio Melotti <[email protected]> Co-authored-by: Erlend E. Aasland <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 590c9db commit 8c95d16

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

getting-started/pull-request-lifecycle.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,12 @@ You should have already :ref:`set up your system <setup>`,
108108

109109
(Learn more about :ref:`good-commits`)
110110

111-
* Then push your work to your GitHub fork::
111+
* If your code isn't linted correctly, :ref:`pre-commit <install-pre-commit>`
112+
will block the commit with an error message, for example::
113+
114+
Doc/library/stdtypes.rst:5718: No newline at end of file. (missing-final-newline)
115+
116+
* Once all linting errors have been fixed, you can push your work to your GitHub fork::
112117

113118
git push origin <branch-name>
114119

getting-started/setup-building.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,18 @@ affected files as described below.)
130130
Patches for the documentation can be made from the same repository; see
131131
:ref:`documenting`.
132132

133+
.. _install-pre-commit:
134+
135+
Install pre-commit as a Git hook
136+
--------------------------------
137+
138+
To make sure your code is linted correctly, we recommend setting up
139+
`pre-commit <https://pre-commit.com#installation>`_ as a Git hook::
140+
141+
$ pre-commit install --allow-missing-config
142+
pre-commit installed at .git/hooks/pre-commit
143+
144+
Now pre-commit will run automatically on ``git commit``.
133145

134146
.. _compiling:
135147

0 commit comments

Comments
 (0)