2023-08-22 23:59:44 +08:00
Install Pre-commit Hook for ESP-IDF Project
2020-10-30 19:31:55 +08:00
===========================================
2023-07-31 19:39:28 +08:00
:link_to_translation:`zh_CN:[中文]`
2023-09-13 17:05:23 +08:00
Install `` pre-commit ``
----------------------
2020-10-30 19:31:55 +08:00
2024-07-12 15:36:07 +08:00
Run `` pip install pre-commit `` .
2020-10-30 19:31:55 +08:00
2023-09-13 17:05:23 +08:00
Install `` pre-commit `` Hook
---------------------------
2020-10-30 19:31:55 +08:00
2023-08-22 23:59:44 +08:00
1. Go to the ESP-IDF project directory.
2020-10-30 19:31:55 +08:00
2023-06-28 13:41:49 +02:00
2. Run `` pre-commit install --allow-missing-config -t pre-commit -t commit-msg `` . Install hook by this approach will let you commit successfully even in branches without the `` .pre-commit-config.yaml ``
2020-10-30 19:31:55 +08:00
2023-08-22 23:59:44 +08:00
3. pre-commit hook will run automatically when you are running `` git commit `` command
2020-10-30 19:31:55 +08:00
2023-09-13 17:05:23 +08:00
Uninstall `` pre-commit `` Hook
2023-07-31 19:39:28 +08:00
-----------------------------
2021-04-19 13:14:25 +03:00
2024-07-12 15:36:07 +08:00
Run `` pre-commit uninstall `` .
2021-04-19 13:14:25 +03:00
2024-07-12 15:36:07 +08:00
Related Documents
-------------------
2020-10-30 19:31:55 +08:00
2021-09-08 17:38:14 +02:00
For detailed usage, please refer to the documentation of pre-commit_.
2020-10-30 19:31:55 +08:00
2022-04-28 14:34:20 +08:00
.. _pre-commit: https://pre-commit.com/
2020-10-30 19:31:55 +08:00
Common Problems For Windows Users
---------------------------------
2021-09-08 17:38:14 +02:00
`` /usr/bin/env: python: Permission denied. ``
2020-10-30 19:31:55 +08:00
2024-07-12 15:36:07 +08:00
If you are in Git Bash, please check the python executable location by run `` which python `` .
2020-10-30 19:31:55 +08:00
2024-07-12 15:36:07 +08:00
If the executable is under `` ~/AppData/Local/Microsoft/WindowsApps/ `` , then it is a link to Windows AppStore, not a real one.
2020-10-30 19:31:55 +08:00
2024-07-12 15:36:07 +08:00
Please install Python manually and update this in your `` PATH `` environment variable.
2021-09-08 17:38:14 +02:00
2023-07-31 19:39:28 +08:00
Your `` USERPROFILE `` contains non-ASCII characters
2021-09-08 17:38:14 +02:00
2024-07-12 15:36:07 +08:00
`` pre-commit `` may fail when initializing an environment for a particular hook when the path of `` pre-commit `` 's cache contains non-ASCII characters. The solution is to set `` PRE_COMMIT_HOME `` to a path containing only standard characters before running pre-commit.
2021-09-08 17:38:14 +02:00
2024-07-12 15:36:07 +08:00
- CMD: `` set PRE_COMMIT_HOME=C:\somepath\pre-commit ``
- PowerShell: `` $Env:PRE_COMMIT_HOME = "C:\somepath\pre-commit" ``
- git bash: `` export PRE_COMMIT_HOME="/c/somepath/pre-commit" ``