Search code examples
pre-commit.com

pre-commit is failing with "Missing required key: rev"


I've been using the pre-commit tool for years! and it's worked great until recently when it started failing with a mysterious error message:

$ pre-commit run flake8 --all-files
An error has occurred: InvalidConfigError: 
==> File .pre-commit-config.yaml
==> At Config()
==> At key: repos
==> At Repository(repo='https://github.com/pre-commit/pre-commit-hooks')
=====> Missing required key: rev
Check the log at /home/asottile/.cache/pre-commit/pre-commit.log

how do I fix this?


Solution

  • your particular case has been warning since may of 2019:

    $ pre-commit run flake8 --all-files
    [WARNING] Unexpected key(s) present on https://github.com/pre-commit/pre-commit-hooks: sha
    flake8...................................................................Passed
    

    you can fix your case by running pre-commit migrate-config which will update sha to rev:

    $ pre-commit migrate-config
    Configuration has been migrated.
    $ pre-commit run flake8 --all-files
    flake8...................................................................Passed
    

    disclaimer: I wrote pre-commit