File: pre_commit_hook.rst

package info (click to toggle)
md-toc 9.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,192 kB
  • sloc: python: 7,901; sh: 942; makefile: 21
file content (42 lines) | stat: -rw-r--r-- 1,390 bytes parent folder | download
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
Pre-commit hook
---------------

This repo provides the following :download:`plugin <../.pre-commit-hooks.yaml>` to be used with the `Pre-commit framework <https://pre-commit.com/>`_

.. literalinclude:: ../.pre-commit-hooks.yaml
   :language: yaml
   :caption: The .pre-commit-hooks.yaml file
   :name: .pre-commit-hooks.yaml

Add a ``.pre-commit-config.yaml`` file in the root of your GIT repo.
Have a look at the ``/.pre-commit-hooks.yaml`` file of this repository for a
full example.

These are the default plugin settings

.. code-block:: yaml
   :caption: A simple example of a .pre-commit-config.yaml file
   :name: .pre-commit-config.yaml simple

    repos:
    -   repo: https://codeberg.org/frnmst/md-toc
        # Release updates (ATOM) https://codeberg.org/frnmst/md-toc/tags.atom
        rev: master # set a GIT tag
        hooks:
        -   id: md-toc

You can override the defaults via the ``args`` parameter, such as

.. code-block:: yaml
   :caption: Example of arguments passed as a pre-commit
   :name: .pre-commit-config.yaml args

    repos:
    -   repo: https://codeberg.org/frnmst/md-toc
        # Release updates (ATOM) https://codeberg.org/frnmst/md-toc/tags.atom
        rev: master # set a GIT tag
        hooks:
        -   id: md-toc
            args: [-p, --skip-lines, '1', redcarpet]  # CLI options

Finally, run ``pre-commit install`` to enable the hook.