Warning
This document is not updated for ESP32H2 yet, so some of the content may not be correct.
This warning was automatically inserted due to the source file being in the add_warnings_pages list.
Install pre-commit Hook for ESP-IDF Project
Required Dependency
Python 3.7.* or above. This is our recommended python version for IDF developers.
If you still have python versions not compatible, update your python versions before installing the pre-commit hook.
Install pre-commit
Run pip install pre-commit
Install pre-commit hook
Go to the IDF Project Directory
Run
pre-commit install --allow-missing-config. Install hook by this approach will let you commit successfully even in branches without the.pre-commit-config.yamlpre-commit hook will run automatically when you’re running
git commitcommand
Uninstall pre-commit
Run pre-commit uninstall
What’s More?
For detailed usage, please refer to the documentation of pre-commit.
Common Problems For Windows Users
/usr/bin/env: python: Permission denied.
If you’re in Git Bash, please check the python executable location by run
which python.If the executable is under
~/AppData/Local/Microsoft/WindowsApps/, then it’s a link to Windows AppStore, not a real one.Please install python manually and update this in your
PATHenvironment variable.
Your %USERPROFILE% contains non-ASCII characters
pre-commitmay fail when initializing an environment for a particular hook when the path ofpre-commit’s cache contains non-ASCII characters. The solution is to setPRE_COMMIT_HOMEto a path containing only standard characters before running pre-commit.
CMD:
set PRE_COMMIT_HOME=C:\somepath\pre-commitPowerShell:
$Env:PRE_COMMIT_HOME = "C:\somepath\pre-commit"git bash:
export PRE_COMMIT_HOME="/c/somepath/pre-commit"