@@ -72,16 +72,27 @@ different formatting, and the configuration file formats are often incompatible.
72
72
Automatic Pre-Commit Hooks
73
73
==========================
74
74
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.
78
78
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
79
89
```
80
- $ pip install pre-commit
81
90
82
- $ pre-commit install
91
+ Then inside the MicroPython repository, register the git hooks for pre-commit
92
+ by running:
83
93
84
- $ pre-commit install --hook-type commit-msg
94
+ ```
95
+ $ pre-commit install --hook-type pre-commit --hook-type commit-msg
85
96
```
86
97
87
98
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
91
102
MicroPython. Pre-commit allows you to see any failure more quickly, and in many
92
103
cases will automatically correct it in your local working copy.
93
104
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
+
94
111
Tips:
95
112
96
113
* To skip pre-commit checks on a single commit, use ` git commit -n ` (for
97
114
` --no-verify ` ).
98
115
* To ignore the pre-commit message format check temporarily, start the commit
99
116
message subject line with "WIP" (for "Work In Progress").
100
117
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.)
103
118
104
119
Python code conventions
105
120
=======================
0 commit comments