pre-commit

Pre-commit hook based on an executable (not git repo)


I'd like to run executable coming from pip that isn't available as a git repository. It seems that documentation assumes anything you'd like to run comes from git repositories: https://pre-commit.com/#plugins. How can I run arbitrary shell commands as pre-commit hooks?


Solution

  • The pre-commit allows to use local sentinel for a repo section. The example config below runs black as installed on the system:

    repos:
    -   repo: local
        hooks:
        - id: black
          name: black
          language: system
          entry: black
          types: [python]