hatch icon indicating copy to clipboard operation
hatch copied to clipboard

[FEATURE] Add pre-commit hook for Hatch project manager

Open mikita-sakalouski opened this issue 4 months ago • 3 comments

Description

This PR adds a new pre-commit hook for Hatch. The hook ensures that Hatch commands are run as part of the pre-commit checks, helping to maintain consistency and quality in the project.

Example

repos:
-   repo: https://github.com/pypa/hatch #local
    rev: hatch-v1.13.0
    hooks:
    -   id : hatch
        name: hatch-config
        always_run: true
        args: [config, set, dirs.env.virtual, ".venv"]
    -   id: hatch-requirements-env-only
        name: hatch-requirements-env-only
        always_run: true
    -   id: hatch-requirements-all
        name: hatch-requirements-all
        always_run: true
    -   id: hatch-requirements-project-only
        name: hatch-requirements-project-only
        always_run: true
    -   id: hatch
        name: hatch-fmt
        always_run: true
        args: [fmt]

Output

> pre-commit run hatch-requirements-env-only
hatch-requirements-env-only..............................................Failed
- hook id: hatch-requirements-env-only
- duration: 0.18s
- files were modified by this hook
> git add requirements.txt 
> pre-commit run hatch-requirements-env-only --verbose
hatch-requirements-env-only..............................................Passed
- hook id: hatch-requirements-env-only
- duration: 0.15s
> pre-commit run hatch-requirements-all --verbose     
hatch-requirements-all...................................................Failed
- hook id: hatch-requirements-all
- duration: 0.12s
- files were modified by this hook
> git add requirements.txt                            
> pre-commit run hatch-requirements-all --verbose
hatch-requirements-all...................................................Passed
- hook id: hatch-requirements-all
- duration: 0.13s
> pre-commit run hatch-requirements-project-only      
hatch-requirements-project-only..........................................Failed
- hook id: hatch-requirements-project-only
- files were modified by this hook
> git add requirements.txt                       
> pre-commit run hatch-requirements-project-only
hatch-requirements-project-only..........................................Passed
> pre-commit run hatch                           
hatch-config.............................................................Passed
hatch-fmt................................................................Passed

Related issue

#1223

mikita-sakalouski avatar Oct 01 '24 21:10 mikita-sakalouski