File: pre-commit-hooks.README.Debian

package info (click to toggle)
pre-commit-hooks 6.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 528 kB
  • sloc: python: 3,605; xml: 4; makefile: 2
file content (65 lines) | stat: -rw-r--r-- 2,047 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
pre-commit-hooks for Debian
===========================

1. pre-commit
-------------

pre-commit is a hook framework for the Git version control system. It allows
managing and maintaining multi-language Git pre-commit hooks.

When using multiple hooks managed by pre-commit, they are usually maintained
in a Git repository on their own and then included in the pre-commit
configuration file, within the repository they are being run in, like this:

  --- .pre-commit-config.yaml ---
  repos:
  -   repo: https://github.com/pre-commit/pre-commit-hooks
      rev: v5.0.0
      hooks:
      -   id: end-of-file-fixer
      -   id: trailing-whitespace-fixer
      -   id: name-tests-test
  [...]
  ---

Running 'pre-commit install' and 'pre-commit run --all-files' then will
automatically download the referenced Git repository (pre-commit-hooks) and
keep it updated.

A demo repository is available upstream:
https://github.com/pre-commit/demo-repo


2. pre-commit-hooks
-------------------

As an alternative to referencing a (remote) Git repository and depend on its
availabilty or the network connectivity to access it, hooks within pre-commit
can also be configured to be used from the local filesystem. This is why the
pre-commit-hooks package is included in Debian.

The above example can be replicated the following way:

  --- .pre-commit-config.yaml ---
  repos:
  -   repo: local
      hooks:
      -   id: end-of-file-fixer
          name: end-of-file-fixer
          entry: end-of-file-fixer
          language: system
      -   id: trailing-whitespace-fixer
          name: trailing-whitespace-fixer
          entry: trailing-whitespace-fixer
          language: system
      -   id: name-tests-test
          name: name-tests-test
          entry: name-test-test
          language: system
  [...]
  ---

In future, the Debian package pre-commit-hooks might include some simplification
(like an include file) way to reference these local pre-commit-hooks easier.

 -- Daniel Baumann <daniel@debian.org>  Mon, 21 Apr 2025 12:55:47 +0200