8000 CODECONVENTIONS.md: Update pre-commit instructions. · jimmo/micropython@4fc543c · GitHub
[go: up one dir, main page]

Skip to content

Commit 4fc543c

Browse files
jimmodpgeorge
authored andcommitted
CODECONVENTIONS.md: Update pre-commit instructions.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
1 parent b8982ec commit 4fc543c

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

CODECONVENTIONS.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,27 @@ different formatting, and the configuration file formats are often incompatible.
7272
Automatic Pre-Commit Hooks
7373
==========================
7474

75-
To have code formatting and commit message conventions automatically checked
76-
using [pre-commit](https://pre-commit.com/), run the following commands in your
77-
local MicroPython directory:
75+
To have code formatting and commit message conventions automatically checked,
76+
a configuration file is provided for the [pre-commit]
77+
(https://pre-commit.com/) tool.
7878

79+
First install `pre-commit`, either from your system package manager or via
80+
`pip`. When installing `pre-commit` via pip, it is recommended to use a
81+
virtual environment. Other sources, such as Brew are also available, see
82+
[the docs](https://pre-commit.com/index.html#install) for details.
83+
84+
```
85+
$ apt install pre-commit # Ubuntu
86+
$ pacman -Sy python-precommit # Arch Linux
87+
$ brew install pre-commit # Brew
88+
$ pip install pre-commit # PyPI
7989
```
80-
$ pip install pre-commit
8190

82-
$ pre-commit install
91+
Then inside the MicroPython repository, register the git hooks for pre-commit
92+
by running:
8393

84-
$ pre-commit install --hook-type commit-msg
94+
```
95+
$ pre-commit install --hook-type pre-commit --hook-type commit-msg
8596
```
8697

8798
pre-commit will now automatically run during `git commit` for both code and
@@ -91,15 +102,19 @@ The same formatting checks will be run by CI for any Pull Request submitted to
91102
MicroPython. Pre-commit allows you to see any failure more quickly, and in many
92103
cases will automatically correct it in your local working copy.
93104

105+
To unregister `pre-commit` from your MicroPython repository, run:
106+
107+
```
108+
$ pre-commit uninstall --hook-type pre-commit --hook-type commit-msg
109+
```
110+
94111
Tips:
95112

96113
* To skip pre-commit checks on a single commit, use `git commit -n` (for
97114
`--no-verify`).
98115
* To ignore the pre-commit message format check temporarily, start the commit
99116
message subject line with "WIP" (for "Work In Progress").
100117

101-
(It is also possible to install pre-commit using Brew or other sources, see
102-
[the docs](https://pre-commit.com/index.html#install) for details.)
103118

104119
Python code conventions
105120
=======================

0 commit comments

Comments
 (0)
0