Ticker

6/recent/ticker-posts

Pre-commit


 

According to official site https://pre-commit.com/

pre-commit is a framework for managing and maintaining multi-language pre-commit hooks.


What is git hooks?

https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

Git allows you to run custom scripts automatically when specific actions happen. These scripts, known as hooks, come in two types: client-side and server-side. Client-side hooks are activated by actions like committing and merging, while server-side hooks are triggered by network activities such as receiving pushed commits.


A sample pre-commit files for terraform code:

repos:
-   repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.3.0
    hooks:
    - id: check-yaml
    - id: end-of-file-fixer
    - id: trailing-whitespace
- repo: https://github.com/psf/black
    rev: 22.10.0
    hooks:
    - id: black

Reference:

Post a Comment

0 Comments