Browse Source

CODECONVENTIONS.md: Update pre-commit instructions.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
pull/9630/head
Jim Mussared 2 years ago
committed by Damien George
parent
commit
4fc543c829
  1. 31
      CODECONVENTIONS.md

31
CODECONVENTIONS.md

@ -72,16 +72,27 @@ different formatting, and the configuration file formats are often incompatible.
Automatic Pre-Commit Hooks
==========================
To have code formatting and commit message conventions automatically checked
using [pre-commit](https://pre-commit.com/), run the following commands in your
local MicroPython directory:
To have code formatting and commit message conventions automatically checked,
a configuration file is provided for the [pre-commit]
(https://pre-commit.com/) tool.
First install `pre-commit`, either from your system package manager or via
`pip`. When installing `pre-commit` via pip, it is recommended to use a
virtual environment. Other sources, such as Brew are also available, see
[the docs](https://pre-commit.com/index.html#install) for details.
```
$ apt install pre-commit # Ubuntu
$ pacman -Sy python-precommit # Arch Linux
$ brew install pre-commit # Brew
$ pip install pre-commit # PyPI
```
$ pip install pre-commit
$ pre-commit install
Then inside the MicroPython repository, register the git hooks for pre-commit
by running:
$ pre-commit install --hook-type commit-msg
```
$ pre-commit install --hook-type pre-commit --hook-type commit-msg
```
pre-commit will now automatically run during `git commit` for both code and
@ -91,6 +102,12 @@ The same formatting checks will be run by CI for any Pull Request submitted to
MicroPython. Pre-commit allows you to see any failure more quickly, and in many
cases will automatically correct it in your local working copy.
To unregister `pre-commit` from your MicroPython repository, run:
```
$ pre-commit uninstall --hook-type pre-commit --hook-type commit-msg
```
Tips:
* To skip pre-commit checks on a single commit, use `git commit -n` (for
@ -98,8 +115,6 @@ Tips:
* To ignore the pre-commit message format check temporarily, start the commit
message subject line with "WIP" (for "Work In Progress").
(It is also possible to install pre-commit using Brew or other sources, see
[the docs](https://pre-commit.com/index.html#install) for details.)
Python code conventions
=======================

Loading…
Cancel
Save