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

pre-commit git hooks described in contribution.md, but no example .pre-commit-config.yaml provided #1398

Open
colin-stubbs opened this issue May 23, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@colin-stubbs
Copy link
Contributor

colin-stubbs commented May 23, 2024

Description

pre-commit git hooks are described in contribution.md, but no example .pre-commit-config.yaml is provided.

By running poetry run pre-commit install this seems to only install .git/hooks/pre-commit.

This pre-commit file correctly runs python pre-commit in the poetry venv, but because a .pre-commit-config.yaml is still missing the commit will always fail until a valid yaml file is created.

(bbot-py3.12) user@dev-box bbot % poetry run pre-commit install
pre-commit installed at .git/hooks/pre-commit
(bbot-py3.12) user@dev-box bbot %
(bbot-py3.12) user@dev-box bbot % cat .git/hooks/pre-commit
#!/usr/bin/env bash
# File generated by pre-commit: https://pre-commit.com
# ID: 138fd403232d2ddd5efb44317e38bf03

# start templated
INSTALL_PYTHON=/Users/user/Library/Caches/pypoetry/virtualenvs/bbot-XnbrUybI-py3.12/bin/python
ARGS=(hook-impl --config=.pre-commit-config.yaml --hook-type=pre-commit)
# end templated

HERE="$(cd "$(dirname "$0")" && pwd)"
ARGS+=(--hook-dir "$HERE" -- "$@")

if [ -x "$INSTALL_PYTHON" ]; then
    exec "$INSTALL_PYTHON" -mpre_commit "${ARGS[@]}"
elif command -v pre-commit > /dev/null; then
    exec pre-commit "${ARGS[@]}"
else
    echo '`pre-commit` not found.  Did you forget to activate your virtualenv?' 1>&2
    exit 1
fi
(bbot-py3.12) user@dev-box bbot % 

Recommended pre-commit git hook config provided in contribution.md,

e.g. something like?

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: 24.4.2
    hooks:
    -   id: black
@colin-stubbs colin-stubbs added the enhancement New feature or request label May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant