install-pre-commit-hook.rst 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Install pre-commit Hook for ESP-IDF Project
  2. ===========================================
  3. Required Dependency
  4. -------------------
  5. Python 3.6.1 or above. This is our recommendation python version for IDF developers.
  6. If you still have python versions not compatible, please do not install pre-commit hook and update your python versions.
  7. Install pre-commit
  8. ------------------
  9. Run ``pip install pre-commit``
  10. Install pre-commit hook
  11. -----------------------
  12. 1. Go to the IDF Project Directory
  13. 2. 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.yaml``
  14. 3. pre-commit hook will run automatically when you're running ``git commit`` command
  15. Uninstall pre-commit
  16. --------------------
  17. Run ``pre-commit uninstall``
  18. What's More?
  19. ------------
  20. For detailed usage, please refer to the documentation of pre-commit_.
  21. .. _pre-commit: https://www.pre-commit.com/
  22. Common Problems For Windows Users
  23. ---------------------------------
  24. ``/usr/bin/env: python: Permission denied.``
  25. If you're in Git Bash or MSYS terminal, please check the python executable location by run ``which python``.
  26. If the executable is under ``~/AppData/Local/Microsoft/WindowsApps/``, then it's a link to Windows AppStore, not a real one.
  27. Please install python manually and update this in your ``PATH`` environment variable.
  28. Your %USERPROFILE% contains non-ASCII characters
  29. ``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.
  30. - CMD: ``set PRE_COMMIT_HOME=C:\somepath\pre-commit``
  31. - PowerShell: ``$Env:PRE_COMMIT_HOME = "C:\somepath\pre-commit"``
  32. - git bash: ``export PRE_COMMIT_HOME="/c/somepath/pre-commit"``