@@ -19,7 +19,7 @@ Add this configuration to your `.pre-commit-config.yaml` file:
1919``` yaml
2020repos :
2121 - repo : https://github.com/cpp-linter/cpp-linter-hooks
22- rev : v1.7 .0
22+ rev : v1.8 .0
2323 hooks :
2424 - id : clang-format
2525 args : [--style=file, --version=21]
@@ -35,12 +35,16 @@ a `compile_commands.json`, which it looks for in `build/` and a few other direct
3535it skips clang-tidy on your machine and fails in CI (see
3636[Compilation database](https://github.com/cpp-linter/cpp-linter-hooks#compilation-database)).
3737
38+ For teams, CI and machines behind a firewall or a company PyPI mirror, also pin the wheel in
39+ ` additional_dependencies` so pre-commit installs it once, with the hook (see
40+ [Install the tool with the hook](https://github.com/cpp-linter/cpp-linter-hooks#install-the-tool-with-the-hook)).
41+
3842# # Usage
3943
4044# ## Custom clang tool version
4145
4246> [!TIP]
43- > The `rev` tag (e.g. `v1.7 .0`) is the **project** version, not the clang tool version. Without
47+ > The `rev` tag (e.g. `v1.8 .0`) is the **project** version, not the clang tool version. Without
4448> `--version`, each hook installs the newest clang-format or clang-tidy wheel on PyPI the first time
4549> it runs and keeps it until pre-commit rebuilds the hook environment, so two machines can run
4650> different LLVM versions with the same configuration. For production use, always pin the tool
@@ -53,12 +57,14 @@ it skips clang-tidy on your machine and fails in CI (see
5357 a wheel, the hook fails and lists some of the versions that exist.
5458- When the hook environment already has a wheel that matches `--version` (or any wheel, without
5559 ` --version` ), the hook uses it and does not contact pypi.org. Otherwise it looks the version up
56- on pypi.org and installs it, so that run needs network access.
60+ on pypi.org and installs it, so that run needs network access. pre-commit runs the hook on
61+ groups of files in parallel; one of them installs the wheel and the others wait for it.
5762
58- # ## Offline and pre-commit.ci
63+ # ## Install the tool with the hook
5964
60- To install the clang tool together with the hook, list the exact wheel in
61- `additional_dependencies` :
65+ We recommend listing the exact wheel in `additional_dependencies`. pre-commit then installs the
66+ clang tool once, when it creates the hook environment, the same way
67+ [mirrors-clang-format](https://github.com/pre-commit/mirrors-clang-format) does :
6268
6369` ` ` yaml
6470 - id: clang-format
@@ -69,11 +75,16 @@ To install the clang tool together with the hook, list the exact wheel in
6975 additional_dependencies: [clang-tidy==21.1.6]
7076` ` `
7177
72- pre-commit installs `additional_dependencies` when it creates the hook environment (for example
73- with `pre-commit install-hooks`), so the hooks need no network access when they run. Use this on
74- [pre-commit.ci](https://pre-commit.ci/), which runs hooks without network access, and behind a
75- firewall. The pinned wheel must match `--version`; otherwise the hook installs the `--version` one
76- at run time.
78+ pre-commit installs `additional_dependencies` with the hook (for example on
79+ ` pre-commit install-hooks` ), through the same package index it uses for the hook itself. The hooks
80+ then never install anything or contact pypi.org when they run, so this works :
81+
82+ - on [pre-commit.ci](https://pre-commit.ci/), which runs hooks without network access,
83+ - behind a firewall or with a company PyPI mirror, where pypi.org may be blocked or slow,
84+ - for teams and CI, where every machine gets exactly the same wheel.
85+
86+ The pinned wheel must match `--version`; otherwise the hook installs the `--version` one at run
87+ time. Without `--version`, the hook uses the pinned wheel.
7788
7889# ## clang-format
7990
@@ -204,7 +215,7 @@ See [Performance optimization](https://github.com/cpp-linter/cpp-linter-hooks#pe
204215` ` ` yaml
205216repos:
206217 - repo: https://github.com/cpp-linter/cpp-linter-hooks
207- rev: v1.7 .0 # includes --fix support
218+ rev: v1.8 .0 # includes --fix support
208219 hooks:
209220 - id: clang-tidy
210221 args: [--fix]
@@ -227,7 +238,7 @@ repository root works too.
227238` ` ` yaml
228239repos:
229240 - repo: https://github.com/cpp-linter/cpp-linter-hooks
230- rev: v1.7 .0
241+ rev: v1.8 .0
231242 hooks:
232243 - id: clang-tidy
233244 # Auto-detects ./build/compile_commands.json if present
@@ -282,7 +293,7 @@ Three self-contained templates plus quick snippets for other common setups.
282293
283294` ` ` yaml
284295- repo: https://github.com/cpp-linter/cpp-linter-hooks
285- rev: v1.7 .0
296+ rev: v1.8 .0
286297 hooks:
287298 - id: clang-format
288299 args: [--style=file, --version=21]
@@ -297,7 +308,7 @@ or `-j`:
297308
298309` ` ` yaml
299310- repo: https://github.com/cpp-linter/cpp-linter-hooks
300- rev: v1.7 .0
311+ rev: v1.8 .0
301312 hooks:
302313 - id: clang-tidy
303314 args: [--version=21, --jobs=4]
@@ -334,7 +345,7 @@ This approach ensures that only modified files are checked, further speeding up
334345` ` ` yaml
335346repos:
336347 - repo: https://github.com/cpp-linter/cpp-linter-hooks
337- rev: v1.7 .0
348+ rev: v1.8 .0
338349 hooks:
339350 - id: clang-format
340351 args: [--style=file, --version=21, --verbose] # Shows processed files
0 commit comments