Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mikita-sakalouski
Copy link

@mikita-sakalouski mikita-sakalouski commented Oct 1, 2024

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
Copy link
Author

@ofek Can you please have a look ?

@ofek
Copy link
Collaborator

ofek commented Oct 2, 2024

I will soon

@mikita-sakalouski
Copy link
Author

@ofek Do I need to adjust anything? Not sure why tests are failing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants