pre-commit: installed git hook should have full path to binary (#77638)
pre-commit currently install impure Git hooks that look for the `pre-commit` binary in PATH. If the user has `pre-commit` loaded via a nix-shell instead of having it installed then GUI editors, such as Intellij, won't be able to use Git commit because the hook fails trying to look for the `pre-commit` binary in PATH. This patch updates the hook template to use the hardcoded path to the `pre-commit` binary if it was found, fallback to using the one from PATH.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
, importlib-metadata
|
||||
, importlib-resources
|
||||
, nodeenv
|
||||
, python
|
||||
, six
|
||||
, toml
|
||||
, virtualenv
|
||||
@@ -22,6 +23,10 @@ buildPythonApplication rec {
|
||||
sha256 = "0l5qg1cw4a0670m96s0ryy5mqz5aslfrrnwpriqgmrnsgdixhj4g";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./hook-tmpl-use-the-hardcoded-path-to-pre-commit.patch
|
||||
];
|
||||
|
||||
propagatedBuildInputs = [
|
||||
aspy-yaml
|
||||
cached-property
|
||||
@@ -38,6 +43,11 @@ buildPythonApplication rec {
|
||||
# slow and impure
|
||||
doCheck = false;
|
||||
|
||||
preFixup = ''
|
||||
substituteInPlace $out/${python.sitePackages}/pre_commit/resources/hook-tmpl \
|
||||
--subst-var-by pre-commit $out
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "A framework for managing and maintaining multi-language pre-commit hooks";
|
||||
homepage = https://pre-commit.com/;
|
||||
|
||||
Reference in New Issue
Block a user